:root {
  --bg: #f4ede3;
  --bg-soft: #f8f3eb;
  --tile: rgba(255, 255, 255, 0.96);
  --tile-line: rgba(125, 111, 93, 0.12);
  --tile-shadow: 0 18px 34px rgba(122, 103, 76, 0.12);
  --ink: #231f1a;
  --muted: #7c6f63;
  --folder-surface: #fae8b1;
  --folder-surface-deep: #f7dd8d;
  --folder-pill: #fff7de;
  --doc-surface: #f1ede4;
  --doc-surface-deep: #ece5d8;
  --doc-line: rgba(130, 117, 96, 0.18);
  --image-surface: linear-gradient(140deg, #f7d5d8, #f2b0b5 52%, #efdad2 100%);
  --audio-surface: linear-gradient(160deg, #ece5da, #ddd2c0 100%);
  --file-surface: #ebe7df;
  --bottom-bar-height: 74px;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Noto Sans SC", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(249, 222, 173, 0.36), transparent 26%),
    linear-gradient(180deg, #f8f3eb 0%, var(--bg) 100%);
}

button,
a,
input,
textarea {
  font: inherit;
  color: inherit;
}

a {
  text-decoration: none;
}

h1,
h2,
h3,
p,
figure {
  margin: 0;
}

.shell {
  width: min(1320px, calc(100vw - 18px));
  margin: 0 auto;
  padding: 10px 0 18px;
}

.app-root {
  min-height: 300px;
}

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

.card {
  min-width: 0;
}

.card-hitarea,
.card-face {
  display: block;
  width: 100%;
  text-align: left;
}

.card-hitarea {
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
}

.card-face {
  display: flex;
  flex-direction: column;
  aspect-ratio: 1 / 1;
  padding: 14px;
  border-radius: 34px;
  background: var(--tile);
  border: 1px solid var(--tile-line);
  box-shadow: var(--tile-shadow);
  overflow: hidden;
  transition: transform 180ms ease, box-shadow 180ms ease, border-color 180ms ease;
}

.card-face--interactive {
  cursor: pointer;
}

.card-face:hover,
.card-face--interactive:hover {
  transform: translateY(-2px);
  box-shadow: 0 22px 36px rgba(122, 103, 76, 0.18);
  border-color: rgba(125, 111, 93, 0.22);
}

.folder-preview,
.doc-preview,
.image-preview,
.audio-preview,
.file-preview {
  position: relative;
  flex: 0 0 62%;
  border-radius: 24px;
  overflow: hidden;
}

.card-meta {
  display: grid;
  gap: 8px;
  align-content: start;
  padding: 12px 2px 0;
  min-height: 0;
}

.card-title {
  font-size: 17px;
  line-height: 1.24;
  font-weight: 700;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-text {
  color: var(--muted);
  line-height: 1.45;
  font-size: 12px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-folder .folder-preview {
  flex: 1 1 auto;
  border-radius: 0;
  overflow: visible;
}

.card-folder .card-meta {
  display: flex;
  flex: 0 0 auto;
  flex-direction: column;
  justify-content: flex-start;
  gap: 0;
  padding: 0 2px 12px;
}

.card-doc .card-title {
  min-height: calc(1.24em * 2);
}

.card-folder .card-face {
  background: linear-gradient(180deg, var(--folder-surface) 0%, var(--folder-surface-deep) 100%);
  border-color: rgba(190, 154, 58, 0.16);
}

.card-doc .doc-preview {
  flex-basis: 74%;
}

.card-doc .card-face {
  position: relative;
  background: linear-gradient(180deg, var(--doc-surface) 0%, var(--doc-surface-deep) 100%);
  border-color: rgba(130, 117, 96, 0.1);
}

.card-doc .card-face::after {
  content: "";
  position: absolute;
  top: 14px;
  right: 14px;
  width: 54px;
  height: 54px;
  background: linear-gradient(135deg, rgba(223, 208, 175, 0.92) 48%, transparent 50%);
  pointer-events: none;
}

.card-doc .doc-preview,
.card-doc .card-meta {
  position: relative;
  z-index: 1;
}

.card-doc .doc-preview {
  background: transparent;
  border: 0;
}

.card-doc .doc-preview::after {
  content: none;
}

.card-doc .card-meta {
  display: flex;
  flex: 1 1 auto;
  align-items: flex-end;
  padding-top: 10px;
}

.card-doc .card-title {
  width: 100%;
}

.card-doc .card-title-main {
  display: inline;
}

.card-doc .card-title-size {
  display: inline;
  margin-left: 0.42em;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  white-space: nowrap;
}

.folder-preview {
  padding-top: 2px;
}

.folder-list {
  display: grid;
  gap: 8px;
  align-content: start;
}

.folder-line {
  min-height: 29px;
  padding: 7px 12px;
  border-radius: 999px;
  background: var(--folder-pill);
  color: #7d611d;
  font-size: 11px;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.doc-preview {
  padding: 16px 16px 20px;
  background: linear-gradient(180deg, var(--doc-surface) 0%, var(--doc-surface-deep) 100%);
  border: 1px solid rgba(130, 117, 96, 0.08);
}

.doc-preview::after {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  width: 54px;
  height: 54px;
  background: linear-gradient(135deg, rgba(223, 208, 175, 0.9) 48%, transparent 50%);
}

.doc-preview-copy {
  position: relative;
  z-index: 1;
  color: #6f665d;
  font-size: 11.5px;
  line-height: 1.48;
  display: -webkit-box;
  -webkit-line-clamp: 9;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.doc-preview-copy::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    repeating-linear-gradient(
      180deg,
      transparent 0 17px,
      var(--doc-line) 17px 20px
    );
  opacity: 0.55;
  pointer-events: none;
}

.doc-preview-copy {
  padding-top: 2px;
}

.image-preview {
  background: var(--image-surface);
}

.image-preview::before {
  content: "";
  position: absolute;
  inset: 14px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.26);
}

.image-preview.has-media {
  background-color: #ede6dc;
  background-image: none;
  background-size: cover;
  background-position: center;
}

.image-preview.has-media::before {
  display: none;
}

.audio-preview {
  display: grid;
  place-items: center;
  background: var(--audio-surface);
  border: 1px solid rgba(130, 117, 96, 0.08);
}

.audio-wave {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.audio-wave span {
  width: 8px;
  border-radius: 999px;
  background: linear-gradient(180deg, #ffffff, #d8bd7f);
  animation: wave 1.1s ease-in-out infinite alternate;
}

.audio-wave span:nth-child(1) { height: 28px; animation-delay: 0s; }
.audio-wave span:nth-child(2) { height: 58px; animation-delay: 0.12s; }
.audio-wave span:nth-child(3) { height: 38px; animation-delay: 0.24s; }
.audio-wave span:nth-child(4) { height: 64px; animation-delay: 0.08s; }
.audio-wave span:nth-child(5) { height: 34px; animation-delay: 0.2s; }
.audio-wave span:nth-child(6) { height: 48px; animation-delay: 0.16s; }

.audio-toggle {
  position: relative;
  z-index: 1;
  min-height: 40px;
  padding: 8px 18px;
  border: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.92);
  color: #3a3026;
  cursor: pointer;
  box-shadow: 0 8px 18px rgba(122, 103, 76, 0.18);
}

.audio-toggle.is-playing {
  background: #f4d48a;
}

.file-preview {
  display: grid;
  place-items: center;
  background: var(--file-surface);
  border: 1px solid rgba(130, 117, 96, 0.08);
}

.file-preview--pdf {
  background: linear-gradient(180deg, #f4e6e6 0%, #eed7d7 100%);
  border-color: rgba(172, 89, 89, 0.14);
}

.file-glyph {
  padding: 10px 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.86);
  color: #7a6f61;
  font-size: 12px;
  letter-spacing: 0.14em;
}

.file-preview--pdf .file-glyph {
  color: #8f3d3d;
}

.detail-shell {
  display: grid;
}

.detail-card {
  border: 1px solid var(--tile-line);
  border-radius: 28px;
  background: var(--tile);
  box-shadow: var(--tile-shadow);
  padding: 22px;
}

.detail-card--media {
  display: grid;
  gap: 16px;
}

.detail-kicker {
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: #a08457;
}

.detail-title {
  margin-top: 8px;
  font-size: clamp(28px, 4vw, 42px);
  line-height: 1.08;
}

.detail-summary {
  margin-top: 10px;
  color: var(--muted);
  line-height: 1.7;
}

.detail-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}

.detail-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 10px 14px;
  border-radius: 999px;
  background: #f7f3ec;
  border: 1px solid var(--tile-line);
}

.markdown-body {
  margin-top: 18px;
  color: #34261e;
  line-height: 1.8;
  overflow-wrap: anywhere;
}

.markdown-body > * {
  max-width: 100%;
  box-sizing: border-box;
}

.markdown-body h1,
.markdown-body h2,
.markdown-body h3,
.markdown-body h4 {
  margin-top: 1.4em;
  margin-bottom: 0.5em;
  line-height: 1.2;
}

.markdown-body p,
.markdown-body ul,
.markdown-body ol,
.markdown-body pre,
.markdown-body blockquote {
  margin-top: 0;
  margin-bottom: 1em;
}

.markdown-body ul,
.markdown-body ol {
  padding-left: 1.5em;
}

.markdown-body code {
  padding: 0.14em 0.38em;
  border-radius: 8px;
  background: rgba(84, 58, 22, 0.08);
  font-family: Consolas, "SFMono-Regular", monospace;
  font-size: 0.95em;
}

.markdown-body pre {
  overflow-x: auto;
  max-width: 100%;
  padding: 14px;
  border-radius: 18px;
  background: #211a16;
  color: #f9f5ef;
  box-sizing: border-box;
}

.markdown-body pre code {
  padding: 0;
  background: transparent;
  color: inherit;
  display: block;
  min-width: max-content;
}

.markdown-body blockquote {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  padding: 12px 16px;
  border-radius: 18px;
  background: rgba(247, 243, 236, 0.88);
  padding-left: 16px;
  border-left: 4px solid rgba(244, 199, 95, 0.9);
  color: var(--muted);
}

.markdown-body table {
  display: block;
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  margin: 0 0 1em;
  border-collapse: collapse;
  border-spacing: 0;
}

.markdown-body th,
.markdown-body td {
  border: 1px solid rgba(125, 111, 93, 0.24);
  padding: 10px 12px;
  text-align: left;
  vertical-align: top;
  background: rgba(255, 255, 255, 0.46);
}

.markdown-body th {
  background: rgba(233, 223, 208, 0.82);
  font-weight: 700;
}

.markdown-body tr:nth-child(even) td {
  background: rgba(247, 243, 236, 0.9);
}

.markdown-body img {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 1em auto;
  border-radius: 18px;
}

.image-stage,
.audio-stage {
  margin-top: 14px;
  border-radius: 24px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.56);
  border: 1px solid var(--tile-line);
}

.viewer-image {
  display: block;
  width: 100%;
  height: auto;
  max-height: min(76vh, 960px);
  object-fit: contain;
  background: #f8f4ec;
}

.detail-audio-player {
  display: block;
  width: 100%;
  min-height: 70px;
}

.state-panel {
  padding: 24px;
  border: 1px solid var(--tile-line);
  border-radius: 28px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: var(--tile-shadow);
}

.state-panel h2 {
  font-size: 28px;
}

.state-panel p,
.empty-copy {
  margin-top: 10px;
  color: var(--muted);
  line-height: 1.7;
}

.bottom-bar {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  width: 100%;
  min-height: var(--bottom-bar-height);
  margin: 0 0 16px;
  padding: 12px;
  border: 1px solid rgba(125, 111, 93, 0.12);
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(18px);
  box-shadow: 0 18px 32px rgba(122, 103, 76, 0.14);
}

.bottom-bar__left,
.bottom-bar__right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.bottom-button,
.bottom-path {
  min-height: 42px;
  padding: 9px 14px;
  border: 1px solid rgba(125, 111, 93, 0.1);
  border-radius: 999px;
  background: #faf7f2;
  color: var(--ink);
  cursor: pointer;
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease;
}

.bottom-button:hover,
.bottom-path:hover {
  transform: translateY(-1px);
  border-color: rgba(125, 111, 93, 0.18);
}

.bottom-button[disabled] {
  cursor: default;
  opacity: 0.64;
}

.bottom-button[disabled]:hover {
  transform: none;
  border-color: rgba(125, 111, 93, 0.1);
}

.bottom-path {
  width: 100%;
  min-width: 0;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

@keyframes wave {
  from {
    transform: scaleY(0.72);
    opacity: 0.78;
  }

  to {
    transform: scaleY(1.04);
    opacity: 1;
  }
}

@media (max-width: 820px) {
  .shell {
    width: min(100vw - 12px, 1240px);
    padding: 8px 0 16px;
  }

  .card-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  .card-face {
    padding: 12px;
    border-radius: 28px;
  }

  .card-folder .folder-preview {
    flex: 1 1 auto;
  }

  .card-doc .doc-preview {
    flex-basis: 72%;
  }

  .detail-card {
    padding: 18px;
  }

  .bottom-bar {
    gap: 8px;
    padding: 10px;
    margin-bottom: 12px;
  }

  .bottom-button,
  .bottom-path {
    min-height: 40px;
    padding: 9px 12px;
  }
}

@media (max-width: 520px) {
  .card-title {
    font-size: 16px;
  }

  .card-text,
  .doc-preview-copy,
  .folder-line,
  .bottom-button,
  .bottom-path {
    font-size: 12px;
  }

  .detail-title {
    font-size: 28px;
  }
}
