html {
  margin: 0;
  background: #181818;
  color: #f5f5f5;
  font-family: 'Cairo', Arial, sans-serif;
}

body {
  margin: 0;
  min-width: 720px;
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
a.secondary-button {
  cursor: pointer;
}

input,
select,
textarea {
  background: #242424;
  border: 1px solid #4d4d4d;
  border-radius: 6px;
  color: #f5f5f5;
  box-sizing: border-box;
}

input,
select {
  min-height: 38px;
  padding: 6px 10px;
}

textarea {
  min-height: 150px;
  padding: 10px;
  resize: vertical;
}

#login {
  width: 400px;
  border-radius: 10px;
  padding: 10px;
  text-align: center;
  height: 160px;
  background-color: rgb(30, 30, 30);
  filter: drop-shadow(10px 10px 15px black);
}

#login .login-btn {
  margin: 20px auto;
}

#login form {
  display: flex;
  flex-direction: column;
  height: 90px;
  align-items: center;
}

.cms-shell {
  width: min(1280px, calc(100% - 48px));
  margin: 0 auto 48px;
}

.cms-toolbar {
  position: sticky;
  top: 58px;
  z-index: 20;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 18px;
  padding: 14px 0;
  background: rgba(24, 24, 24, 0.96);
  border-bottom: 1px solid #333;
}

#previewLinkAnchor {
  min-height: 0px;
}

.toolbar-primary,
.toolbar-secondary,
.cms-status-row,
.project-card-header,
.project-card-actions,
.image-row-actions,
.dialog-actions,
.form-actions,
.mode-selector {
  display: flex;
  align-items: center;
  gap: 10px;
}

.toolbar-primary,
.toolbar-secondary {
  flex-wrap: wrap;
}

.toolbar-primary {
  align-items: flex-end;
}

.toolbar-secondary {
  align-items: flex-end;
  justify-content: flex-end;
}

.field-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
  color: #bdbdbd;
  font-size: 13px;
}

.portfolio-field select {
  width: 300px;
}

.cms-status-row {
  justify-content: space-between;
  padding: 26px 0 18px;
}

.cms-status-row h1 {
  margin: 0;
  font-size: 28px;
  font-weight: 600;
  line-height: 1.1;
}

.cms-status-row p {
  margin: 6px 0 0;
  color: #bdbdbd;
}

.primary-button,
.secondary-button,
.danger-button,
.quiet-danger-button,
.mode-btn {
  min-height: 38px;
  border-radius: 6px;
  border: 1px solid transparent;
  padding: 7px 13px;
  color: #f8f8f8;
  text-decoration: none;
  line-height: 22px;
}

.primary-button {
  background: #2f7d5f;
  border-color: #3d9f79;
}

.secondary-button {
  background: #282828;
  border-color: #555;
}

.danger-button {
  background: #8d2f35;
  border-color: #b94a51;
}

.quiet-danger-button {
  background: #2b2021;
  border-color: #8d2f35;
  color: #f2c2c6;
}

.quiet-danger-button:hover {
  background: #3a2426;
  border-color: #b94a51;
  color: #ffffff;
}

.settings-back-link {
  display: inline-flex;
  align-items: center;
}

.storage-meter {
  width: 260px;
  min-height: 38px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  padding: 6px 10px;
  border: 1px solid #444;
  border-radius: 6px;
  background: #202020;
  box-sizing: border-box;
}

.storage-meter-header {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  color: #aaa;
  font-size: 12px;
  line-height: 1.2;
}

.storage-meter-header strong {
  color: #f5f5f5;
  font-weight: 600;
  white-space: nowrap;
}

.storage-meter-track {
  height: 7px;
  overflow: hidden;
  border-radius: 999px;
  background: #111;
}

.storage-meter-fill {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: #3d9f79;
  transition: width 0.2s ease, background 0.2s ease;
}

.storage-meter-fill.warning {
  background: #c29d42;
}

.storage-meter-fill.danger {
  background: #b94a51;
}

.session-count-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #242424;
  padding: 3px 10px;
  border-radius: 20px;
  color: #3d9f79;
  text-decoration: none;
  font-size: 12px;
  margin-left: 10px;
  border: 1px solid #444;
  transition: all 0.2s ease;
  vertical-align: middle;
}

.session-count-link:hover {
  background: #2f2f2f;
  border-color: #3d9f79;
  color: #4ed3a2;
}

.session-count-link .icon {
  font-size: 14px;
}

.icon-button,
.card-icon-button {
  width: 34px;
  height: 34px;
  min-width: 34px;
  border: 1px solid #555;
  border-radius: 6px;
  background-color: #282828;
  background-position: center;
  background-repeat: no-repeat;
  background-size: 18px;
}

.rename-portfolio-btn,
.rename-project-btn,
.edit-image-btn {
  background-image: url('/images/edit.png');
}

.delete-project-btn,
.delete-image-btn {
  background-image: url('/images/trash.png');
}

.drag-project-handle,
.drag-image-handle {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border: 1px solid #444;
  border-radius: 6px;
  color: #aaa;
  cursor: grab;
  flex: 0 0 auto;
}

.drag-project-handle:active,
.drag-image-handle:active {
  cursor: grabbing;
}

.curation-layout {
  display: grid;
  grid-template-columns: minmax(300px, 360px) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.portfolio-pane,
.project-library {
  min-width: 0;
}

.portfolio-pane {
  position: sticky;
  top: 150px;
  max-height: calc(100vh - 174px);
  display: flex;
  flex-direction: column;
  border: 1px solid #333;
  border-radius: 8px;
  background: #1d1d1d;
  overflow: hidden;
}

.pane-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border-bottom: 1px solid #333;
  margin-bottom: 10px;
}

.portfolio-pane-header h2 {
  overflow-wrap: anywhere;
}

.pane-header h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
}

.pane-header p {
  margin: 4px 0 0;
  color: #aaa;
  font-size: 13px;
}

.included-project-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px;
  overflow: auto;
}

.included-project-row {
  display: grid;
  grid-template-columns: auto 48px minmax(0, 1fr) auto;
  align-items: center;
  gap: 9px;
  padding: 8px;
  border: 1px solid #393939;
  border-radius: 8px;
  background: #242424;
}

.included-project-row img,
.included-project-thumb-placeholder {
  width: 48px;
  height: 48px;
  border-radius: 6px;
  object-fit: cover;
  background: #141414;
}

.included-project-thumb-placeholder {
  display: grid;
  place-items: center;
  color: #777;
  font-size: 11px;
}

.included-project-title {
  min-width: 0;
}

.included-project-title strong {
  display: block;
  line-height: 1.15;
  overflow-wrap: anywhere;
}

.included-project-title span {
  display: block;
  margin-top: 3px;
  color: #aaa;
  font-size: 12px;
}

.remove-from-portfolio-btn {
  width: 30px;
  height: 30px;
  border: 1px solid #704348;
  border-radius: 6px;
  background: transparent;
  color: #f0b2b8;
  font-size: 18px;
  line-height: 1;
}

.project-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 14px;
}

.project-card {
  border: 1px solid #3d3d3d;
  border-radius: 8px;
  background: #202020;
  min-height: 184px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.project-card[data-enabled="true"] {
  border-color: #4d8f6e;
  background: #203128;
}

.project-card[data-enabled="true"] .project-card-header {
  border-bottom-color: #375d49;
}

.project-card-header {
  padding: 10px;
  border-bottom: 1px solid #333;
}

.project-thumb,
.project-thumb-placeholder {
  width: 72px;
  height: 72px;
  border-radius: 6px;
  background: #111;
  flex: 0 0 auto;
}

.project-thumb {
  object-fit: cover;
}

.project-thumb-placeholder {
  color: #888;
  display: grid;
  place-items: center;
}

.project-card-title {
  min-width: 0;
  flex: 1;
}

.project-card-title h2 {
  margin: 0;
  font-size: 19px;
  font-weight: 600;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.project-card-title p,
.project-meta {
  margin: 5px 0 0;
  color: #aaa;
  font-size: 13px;
}

.project-card-body {
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex: 1;
}

.project-card-actions {
  justify-content: space-between;
  margin-top: auto;
}

.library-status {
  color: #a9d8bf;
  font-size: 13px;
}

.remove-library-project-btn {
  background: #244d3a;
  border-color: #4d8f6e;
  color: #e8f6ee;
}

.thumbnail-label {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: #ddd;
}

.dialog-layer {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: 28px;
  background: rgba(0, 0, 0, 0.72);
}

.dialog-layer[hidden] {
  display: none;
}

.dialog,
.editor-dialog {
  width: min(720px, calc(100vw - 56px));
  max-height: calc(100vh - 56px);
  overflow: auto;
  background: #202020;
  border: 1px solid #505050;
  border-radius: 8px;
  box-shadow: 0 20px 80px rgba(0, 0, 0, 0.55);
}

.editor-dialog {
  width: min(1040px, calc(100vw - 56px));
}

.dialog-header,
.dialog-body,
.dialog-footer {
  padding: 18px;
}

.dialog-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  border-bottom: 1px solid #343434;
}

.dialog-header h2,
.dialog-header h3 {
  margin: 0;
  font-size: 22px;
}

.dialog-header p {
  margin: 5px 0 0;
  color: #aaa;
}

.dialog-body {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.dialog-footer {
  border-top: 1px solid #343434;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.close-dialog-btn {
  width: 34px;
  height: 34px;
  border-radius: 6px;
  border: 1px solid #555;
  background: #282828;
  color: #fff;
  font-size: 22px;
  line-height: 1;
}

.image-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.image-row {
  display: grid;
  grid-template-columns: auto 86px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 10px;
  border: 1px solid #3a3a3a;
  border-radius: 8px;
  background: #242424;
}

.image-row img,
.image-row-placeholder {
  width: 86px;
  height: 86px;
  border-radius: 6px;
  object-fit: cover;
  background: #151515;
}

.image-row-placeholder {
  display: grid;
  place-items: center;
  color: #888;
  font-size: 12px;
}

.image-row-title {
  min-width: 0;
}

.image-row-title strong {
  display: block;
  overflow-wrap: anywhere;
}

.image-row-title span {
  display: block;
  color: #aaa;
  font-size: 13px;
  overflow-wrap: anywhere;
}

.item-form {
  border: 1px solid #3a3a3a;
  border-radius: 8px;
  padding: 14px;
  background: #242424;
  display: grid;
  gap: 12px;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.form-grid .full-width {
  grid-column: 1 / -1;
}

.mode-selector {
  flex-wrap: wrap;
}

.mode-btn {
  background: #1d1d1d;
  border-color: #555;
}

.mode-btn.selected {
  background: #315f7d;
  border-color: #4b94c4;
}


.storage-hint {
  margin: 8px 0 0;
}

.storage-hint a {
  color: #4ed3a2;
  font-weight: 600;
}

.storage-hint-error {
  color: #f2c2c6;
}

.mode-content {
  display: none;
}

.mode-content.active {
  display: block;
}

.image-picker-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 10px;
  max-height: 300px;
  overflow: auto;
  padding: 8px;
  border: 1px solid #3a3a3a;
  border-radius: 8px;
}

.picker-image {
  border: 2px solid transparent;
  border-radius: 6px;
  padding: 6px;
  background: #1d1d1d;
  cursor: pointer;
}

.picker-image.selected {
  border-color: #4b94c4;
}

.picker-image img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 4px;
}

.picker-image-name {
  margin-top: 5px;
  color: #bbb;
  font-size: 12px;
  overflow-wrap: anywhere;
}

.empty-state,
.loading-state {
  grid-column: 1 / -1;
  border: 1px dashed #555;
  border-radius: 8px;
  padding: 28px;
  color: #aaa;
  text-align: center;
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 1200;
  max-width: 420px;
  padding: 12px 14px;
  border-radius: 8px;
  background: #f5f5f5;
  color: #191919;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4);
}

.toast.error {
  background: #f2c2c6;
}

@media (max-width: 820px) {
  body {
    min-width: 0;
  }

  .cms-shell {
    width: min(100% - 24px, 1280px);
  }

  .cms-toolbar {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .cms-status-row {
    align-items: stretch;
    flex-direction: column;
  }

  .toolbar-primary,
  .toolbar-secondary {
    justify-content: flex-start;
  }

  .portfolio-field select {
    width: min(100%, 320px);
  }

  .storage-meter {
    width: min(100%, 320px);
  }

  .curation-layout {
    grid-template-columns: 1fr;
  }

  .portfolio-pane {
    position: static;
    max-height: none;
  }

  .project-grid {
    grid-template-columns: 1fr;
  }

  .image-row {
    grid-template-columns: auto 72px minmax(0, 1fr);
  }

  .image-row-actions {
    grid-column: 1 / -1;
    justify-content: flex-end;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }
}

.available-project-card {
  cursor: grab;
}

.available-project-card:active {
  cursor: grabbing;
}