:root {
  --bg: #f4efe7;
  --bg-2: #e9e2d3;
  --surface: rgba(255, 255, 255, 0.78);
  --surface-strong: #fffdf8;
  --text: #1f1a17;
  --muted: #766a5f;
  --accent: #c96b3f;
  --accent-2: #2d7c73;
  --danger: #c84b4b;
  --shadow: 0 18px 40px rgba(50, 36, 25, 0.12);
  --radius-lg: 28px;
  --radius-md: 20px;
  --radius-sm: 14px;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  color: var(--text);
  font-family: "Aptos", "Segoe UI", "Noto Sans SC", sans-serif;
  background:
    radial-gradient(circle at top left, rgba(240, 179, 79, 0.25), transparent 30%),
    radial-gradient(circle at top right, rgba(45, 124, 115, 0.18), transparent 28%),
    linear-gradient(180deg, var(--bg), var(--bg-2));
  overflow: hidden;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.25) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.18) 1px, transparent 1px);
  background-size: 46px 46px;
  mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.35), transparent 80%);
  opacity: 0.35;
}

button,
input,
textarea,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app {
  height: 100%;
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr) 360px;
  gap: 18px;
  padding: 18px;
}

.panel {
  background: var(--surface);
  backdrop-filter: blur(18px);
  border: 1px solid rgba(255, 255, 255, 0.55);
  box-shadow: var(--shadow);
  border-radius: var(--radius-lg);
  overflow: hidden;
  min-height: 0;
}

.left,
.workspace,
.right {
  display: flex;
  flex-direction: column;
}

.hero {
  padding: 22px;
  color: #fff7ef;
  background:
    linear-gradient(135deg, rgba(38, 32, 28, 0.94), rgba(56, 46, 37, 0.9)),
    radial-gradient(circle at top right, rgba(240, 179, 79, 0.3), transparent 32%);
  position: relative;
  overflow: hidden;
}

.hero::after {
  content: "";
  position: absolute;
  inset: auto -36px -62px auto;
  width: 180px;
  height: 180px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(240, 179, 79, 0.36), transparent 68%);
}

.brand {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.brand h1 {
  margin: 0;
  font-size: 22px;
  letter-spacing: 0.08em;
  font-weight: 800;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
}

.badge {
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.16);
  color: #f8e8d8;
  font-size: 12px;
}

.hero p {
  margin: 14px 0 0;
  max-width: 24ch;
  color: rgba(255, 247, 239, 0.82);
  line-height: 1.6;
}

.quick-stats {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  padding: 14px 18px 18px;
}

.stat {
  padding: 12px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(54, 38, 28, 0.08);
}

.stat .value {
  display: block;
  font-size: 22px;
  font-weight: 800;
}

.stat .label {
  display: block;
  margin-top: 6px;
  font-size: 12px;
  color: var(--muted);
}

.section {
  padding: 0 18px 18px;
}

.section h2 {
  margin: 0 0 12px;
  font-size: 13px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.tool-row,
.searchbar,
.tag-cloud,
.inspector-block,
.dropzone {
  border: 1px solid rgba(56, 40, 27, 0.08);
  background: rgba(255, 255, 255, 0.72);
  border-radius: var(--radius-sm);
}

.tool-row {
  display: flex;
  gap: 10px;
  padding: 10px;
  flex-wrap: wrap;
}

.primary-btn,
.ghost-btn,
.mini-btn {
  border: 0;
  border-radius: 999px;
  transition:
    transform 0.16s ease,
    background 0.16s ease,
    color 0.16s ease,
    box-shadow 0.16s ease;
}

.primary-btn,
.ghost-btn {
  padding: 11px 14px;
  font-weight: 700;
}

.mini-btn {
  padding: 8px 12px;
  font-size: 12px;
  background: rgba(255, 255, 255, 0.84);
  color: var(--text);
  border: 1px solid rgba(56, 40, 27, 0.08);
}

.primary-btn {
  background: linear-gradient(135deg, var(--accent), #da8a63);
  color: #fff;
  box-shadow: 0 10px 18px rgba(201, 107, 63, 0.22);
}

.ghost-btn {
  background: rgba(255, 255, 255, 0.84);
  color: var(--text);
  border: 1px solid rgba(56, 40, 27, 0.08);
}

.primary-btn:hover,
.ghost-btn:hover,
.mini-btn:hover,
.chip:hover,
.card:hover {
  transform: translateY(-1px);
}

.tag-cloud {
  padding: 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.88);
  color: var(--muted);
  border: 1px solid rgba(56, 40, 27, 0.08);
  transition: transform 0.16s ease, background 0.16s ease, color 0.16s ease;
}

.chip.active {
  background: rgba(201, 107, 63, 0.12);
  color: var(--accent);
  border-color: rgba(201, 107, 63, 0.22);
}

.tag-count {
  font-size: 10px;
  opacity: 0.7;
  margin-left: 4px;
}

.inspector-block {
  padding: 14px;
  color: var(--muted);
  line-height: 1.6;
}

.workspace {
  gap: 14px;
  min-width: 0;
}

.workspace-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 18px 18px 0;
}

.workspace-copy {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  flex: 1;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(45, 124, 115, 0.12);
  color: var(--accent-2);
  font-size: 12px;
  font-weight: 700;
  flex: 0 0 auto;
}

.workspace-title {
  font-size: 20px;
  font-weight: 800;
  white-space: nowrap;
}

.toolbar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: center;
}

.statusline {
  padding: 0;
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
  margin-left: auto;
}

.statusline strong {
  color: var(--text);
}

.editor-shell {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 0 18px 18px;
}

.editor-grid {
  display: grid;
  gap: 12px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(56, 40, 27, 0.08);
  border-radius: var(--radius-lg);
  padding: 16px;
}

.detail-field {
  display: grid;
  gap: 6px;
}

.detail-field label {
  font-size: 12px;
  color: var(--muted);
}

.detail-field input,
.detail-field textarea {
  width: 100%;
  border-radius: 14px;
  border: 1px solid rgba(56, 40, 27, 0.08);
  background: rgba(255, 255, 255, 0.9);
  padding: 10px 12px;
  outline: 0;
  color: var(--text);
  font-size: 13px;
}

.detail-field textarea {
  min-height: 360px;
  height: 48vh;
  resize: vertical;
  line-height: 1.65;
}

.dropzone {
  padding: 14px;
  color: var(--muted);
  line-height: 1.6;
  border-style: dashed;
  background:
    linear-gradient(135deg, rgba(45, 124, 115, 0.12), rgba(240, 179, 79, 0.12)),
    rgba(255, 255, 255, 0.8);
}

.attachments-block {
  display: grid;
  gap: 10px;
  padding: 14px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(56, 40, 27, 0.08);
}

.attachments-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.attachments-left {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.dropzone-mini {
  width: 48px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  border: 1px dashed rgba(45, 124, 115, 0.45);
  background: rgba(45, 124, 115, 0.1);
  color: var(--accent-2);
  font-size: 12px;
  font-weight: 700;
  user-select: none;
}

.attachments-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 10px;
}

.attachment-card {
  margin: 0;
  display: grid;
  gap: 8px;
  padding: 10px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(56, 40, 27, 0.08);
}

.attachment-card img {
  width: 100%;
  max-height: 180px;
  object-fit: contain;
  border-radius: 12px;
  background: #f7f2e8;
}

.attachment-card figcaption {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
}

.detail-image {
  width: 100%;
  max-height: 70vh;
  object-fit: contain;
  border-radius: 16px;
  background: #f7f2e8;
}

.image-modal {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(18, 15, 12, 0.72);
  z-index: 30;
}

.image-modal.hidden {
  display: none;
}

.image-modal-content {
  position: relative;
  width: min(1100px, 96vw);
  max-height: 92vh;
  display: grid;
  gap: 12px;
}

.image-modal-viewport {
  max-height: 86vh;
  overflow: auto;
  border-radius: 20px;
  background: #111;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.28);
  display: flex;
  align-items: center;
  justify-content: center;
}

.image-modal-viewport img {
  display: block;
  width: auto;
  height: auto;
  max-width: none;
  max-height: none;
  border-radius: 0;
  margin: auto;
}

.image-modal-bar {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  color: #fff;
}

.image-modal-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

.image-modal-close {
  border: 0;
  border-radius: 999px;
  padding: 10px 14px;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}

.image-modal-copy {
  border: 0;
  border-radius: 999px;
  padding: 10px 14px;
  background: rgba(45, 124, 115, 0.95);
  color: #fff;
}

body[data-theme="dark"] {
  color-scheme: dark;
  --bg: #111413;
  --bg-2: #171c1b;
  --surface: rgba(22, 26, 25, 0.82);
  --surface-strong: #1a1f1e;
  --text: #f3efe7;
  --muted: #b4aba0;
  --accent: #f09b6d;
  --accent-2: #7fd0c3;
  --danger: #f06b6b;
  --shadow: 0 18px 40px rgba(0, 0, 0, 0.34);
}

body[data-theme="dark"]::before {
  opacity: 0.12;
  mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.2), transparent 80%);
}

body[data-theme="dark"] .stat,
body[data-theme="dark"] .tool-row,
body[data-theme="dark"] .searchbar,
body[data-theme="dark"] .tag-cloud,
body[data-theme="dark"] .inspector-block,
body[data-theme="dark"] .dropzone,
body[data-theme="dark"] .editor-grid,
body[data-theme="dark"] .attachments-block,
body[data-theme="dark"] .attachment-card,
body[data-theme="dark"] .mini-btn,
body[data-theme="dark"] .ghost-btn,
body[data-theme="dark"] .select,
body[data-theme="dark"] .card,
body[data-theme="dark"] .empty,
body[data-theme="dark"] .detail-field input,
body[data-theme="dark"] .detail-field textarea,
body[data-theme="dark"] .image-modal-close,
body[data-theme="dark"] .image-modal-copy {
  background: rgba(25, 29, 28, 0.92);
  color: var(--text);
  border-color: rgba(255, 255, 255, 0.08);
}

body[data-theme="dark"] .mini-btn,
body[data-theme="dark"] .ghost-btn,
body[data-theme="dark"] .select,
body[data-theme="dark"] .detail-field input,
body[data-theme="dark"] .detail-field textarea {
  background: rgba(255, 255, 255, 0.05);
}

body[data-theme="dark"] .hero {
  background:
    linear-gradient(135deg, rgba(8, 9, 9, 0.96), rgba(25, 29, 28, 0.96)),
    radial-gradient(circle at top right, rgba(240, 155, 109, 0.18), transparent 32%);
}

body[data-theme="dark"] .badge {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.1);
  color: #f5e8da;
}

body[data-theme="dark"] .dropzone {
  background:
    linear-gradient(135deg, rgba(127, 208, 195, 0.12), rgba(240, 155, 109, 0.08)),
    rgba(255, 255, 255, 0.04);
}

body[data-theme="dark"] .primary-btn {
  box-shadow: 0 10px 18px rgba(240, 155, 109, 0.18);
}

.detail-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.muted {
  color: var(--muted);
}

.right {
  padding: 18px;
  gap: 14px;
  min-width: 0;
}

.inspector {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 0;
}

.inspector-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.inspector-head h2 {
  margin: 0;
  font-size: 18px;
}

.searchbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
}

.searchbar input {
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
}

.select {
  width: 100%;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(56, 40, 27, 0.08);
  background: rgba(255, 255, 255, 0.84);
  color: var(--text);
}

.finder-content {
  flex: 1;
  min-height: 0;
  overflow: auto;
}

.grid {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.card {
  background: var(--surface-strong);
  border: 1px solid rgba(56, 40, 27, 0.08);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: 0 10px 24px rgba(46, 34, 24, 0.08);
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
  animation: rise 0.32s ease;
}

.card.selected {
  border-color: rgba(201, 107, 63, 0.46);
  box-shadow: 0 0 0 2px rgba(201, 107, 63, 0.18), 0 18px 32px rgba(46, 34, 24, 0.12);
}

.card-body {
  padding: 14px;
  display: grid;
  gap: 8px;
}

.meta-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 12px;
}

.card-title {
  margin: 0;
  font-size: 15px;
  line-height: 1.35;
}

.card-text {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.badge-pill {
  padding: 5px 8px;
  border-radius: 999px;
  background: rgba(45, 124, 115, 0.1);
  color: var(--accent-2);
  font-size: 11px;
}

.empty {
  min-height: 260px;
  display: grid;
  place-items: center;
  text-align: center;
  border: 1px dashed rgba(56, 40, 27, 0.12);
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.55);
  color: var(--muted);
  padding: 30px;
}

.empty h3 {
  margin: 0 0 8px;
  color: var(--text);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%) translateY(16px);
  background: rgba(34, 28, 23, 0.94);
  color: #fff;
  padding: 12px 16px;
  border-radius: 999px;
  box-shadow: 0 18px 32px rgba(0, 0, 0, 0.18);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s ease, transform 0.22s ease;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.hidden {
  display: none !important;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 1280px) {
  body {
    overflow: auto;
  }

  .app {
    grid-template-columns: 280px minmax(0, 1fr);
    height: auto;
    min-height: 100%;
  }

  .right {
    grid-column: 1 / -1;
  }
}

@media (max-width: 920px) {
  .app {
    grid-template-columns: 1fr;
    padding: 12px;
  }

  .workspace-top {
    flex-direction: column;
    align-items: stretch;
  }

  .toolbar {
    justify-content: flex-start;
  }

  .workspace-title {
    white-space: normal;
  }
}
