:root {
    --bg: #ffffff;
    --panel: #ffffff;
    --panel-strong: #ffffff;
    --ink: #25211d;
    --muted: #746d63;
    --line: #e1d8c8;
    --accent: #315f72;
    --accent-soft: #d7e9ed;
    --green: #607a54;
    --rose: #9e665e;
    --shadow: 0 18px 45px rgba(64, 50, 34, 0.12);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  }

  * {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
  }

  [hidden] {
    display: none !important;
  }

  body {
    margin: 0;
    min-height: 100vh;
    background: #ffffff;
    color: var(--ink);
    -webkit-text-size-adjust: 100%;
  }

  button,
  input,
  select,
  textarea {
    font: inherit;
    font-size: 16px;
  }

  button {
    touch-action: manipulation;
  }

  .app-shell {
    display: grid;
    grid-template-columns: 280px minmax(0, 1fr);
    min-height: 100vh;
  }

  .sidebar {
    padding: 24px 18px;
    border-right: 1px solid var(--line);
    background: #ffffff;
  }

  .brand {
    display: flex;
    gap: 14px;
    align-items: center;
    margin-bottom: 28px;
  }

  .brand-mark {
    display: grid;
    width: 44px;
    height: 44px;
    place-items: center;
    border-radius: 8px;
    background: var(--accent);
    color: white;
    font-weight: 800;
  }

  h1,
  h2,
  p {
    margin: 0;
  }

  h1 {
    font-size: 21px;
  }

  h2 {
    font-size: clamp(26px, 4vw, 42px);
    letter-spacing: 0;
  }

  .brand p,
  .eyebrow,
  small {
    color: var(--muted);
  }

  .tabs {
    display: grid;
    gap: 8px;
  }

  .tab-button {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 13px 14px;
    border: 1px solid transparent;
    border-radius: 8px;
    background: transparent;
    color: var(--ink);
    cursor: pointer;
    text-align: left;
  }

  .tab-button[aria-selected="true"] {
    border-color: var(--line);
    background: var(--panel-strong);
    box-shadow: 0 10px 24px rgba(49, 95, 114, 0.1);
  }

  .workspace {
    min-width: 0;
    padding: 28px;
  }

  .topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 22px;
  }

  .eyebrow {
    margin-bottom: 4px;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
  }

  .filters,
  .list-panel,
  .detail-panel {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #ffffff;
    box-shadow: var(--shadow);
  }

  .filters {
    display: grid;
    grid-template-columns: minmax(260px, 0.8fr) minmax(0, 2.4fr);
    gap: 18px;
    align-items: start;
    padding: 16px;
    margin-bottom: 18px;
  }

  .search,
  .field {
    display: grid;
    align-self: start;
    gap: 6px;
    color: var(--muted);
    font-size: 12px;
  }

  input,
  select,
  textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: white;
    color: var(--ink);
    padding: 11px 12px;
    outline: none;
  }

  .search input,
  .field select,
  .field input:not([type="hidden"]) {
    min-height: 48px;
  }

  input:focus,
  select:focus,
  textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
  }

  .filter-grid {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 12px;
  }

  .filter-grid .field {
    flex: 1 1 210px;
    min-width: 190px;
  }

  .filter-grid .field select {
    height: 48px;
  }

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

  .content-grid.has-detail {
    grid-template-columns: minmax(0, 1fr) minmax(380px, 0.95fr);
  }

  .panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px;
    border-bottom: 1px solid var(--line);
  }

  .records {
    display: grid;
    max-height: none;
    overflow: visible;
    padding: 12px;
  }

  .records-table {
    display: grid;
    gap: 6px;
  }

  .records-header,
  .record-row {
    display: grid;
    grid-template-columns: var(--columns);
    gap: 10px;
    align-items: center;
  }

  .records-header {
    position: sticky;
    top: 0;
    z-index: 2;
    padding: 9px 12px;
    border-bottom: 1px solid var(--line);
    background: #ffffff;
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.06em;
  }

  .record-row {
    width: 100%;
    min-height: 50px;
    padding: 10px 12px;
    border: 1px solid var(--row-border, var(--line));
    border-radius: 8px;
    background: linear-gradient(90deg, var(--row-bg, rgba(255, 255, 255, 0.88)), rgba(255, 255, 255, 0.86));
    color: var(--ink);
    cursor: pointer;
    text-align: left;
    -webkit-appearance: none;
    appearance: none;
    box-shadow: inset 4px 0 0 var(--row-accent, transparent);
  }

  .record-row:hover,
  .record-row.active {
    border-color: var(--accent);
    background: linear-gradient(90deg, var(--row-bg-hover, #fbfdff), #ffffff);
  }

  .record-title {
    display: grid;
    min-width: 0;
    gap: 2px;
  }

  .record-title.with-cover {
    grid-template-columns: 42px minmax(0, 1fr);
    align-items: center;
    gap: 10px;
  }

  .record-title-text {
    display: grid;
    min-width: 0;
    gap: 2px;
  }

  .album-cover {
    position: relative;
    display: grid;
    place-items: center;
    flex: 0 0 auto;
    overflow: hidden;
    border: 1px solid color-mix(in srgb, var(--row-accent, var(--accent)) 25%, var(--line));
    border-radius: 10px;
    background:
      linear-gradient(135deg, rgba(255,255,255,.65), rgba(255,255,255,.2)),
      color-mix(in srgb, var(--row-accent, var(--accent)) 12%, white);
    color: color-mix(in srgb, var(--row-accent, var(--accent)) 75%, #17313a);
    font-weight: 900;
    box-shadow: 0 5px 12px rgba(64, 50, 34, 0.08);
  }

  .album-cover-list {
    width: 42px;
    height: 42px;
  }

  .album-cover-detail {
    width: 92px;
    height: 92px;
    border-radius: 18px;
    font-size: 28px;
  }

  .album-cover img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
  }

  .album-cover.loading::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,.72), transparent);
    animation: cover-shimmer 1.2s infinite;
    transform: translateX(-100%);
  }

  .album-cover.missing {
    opacity: .72;
  }

  @keyframes cover-shimmer {
    to { transform: translateX(100%); }
  }

  .record-title strong,
  .record-title small,
  .record-cell {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .record-cell {
    min-width: 0;
    color: #4a443d;
  }

  .record-card {
    display: grid;
    grid-template-columns: 44px minmax(0, 1fr) auto;
    gap: 10px;
    align-items: center;
    width: 100%;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: white;
    color: var(--ink);
    cursor: pointer;
    text-align: left;
  }

  .group-label {
    position: sticky;
    top: 39px;
    z-index: 1;
    padding: 10px 6px 6px;
    background: #ffffff;
    color: var(--muted);
    font-size: 13px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    grid-column: 1 / -1;
  }

  .record-card:hover,
  .record-card.active {
    border-color: var(--accent);
    background: #fbfdff;
  }

  .record-number {
    color: var(--muted);
    font-variant-numeric: tabular-nums;
  }

  .record-main {
    display: grid;
    min-width: 0;
    gap: 3px;
  }

  .record-main strong,
  .record-main small {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .record-score {
    min-width: 40px;
    padding: 5px 8px;
    border-radius: 8px;
    background: color-mix(in srgb, var(--row-accent, var(--accent)) 15%, white);
    color: color-mix(in srgb, var(--row-accent, var(--accent)) 70%, #17313a);
    font-weight: 700;
    text-align: center;
  }

  .detail-panel {
    min-height: 0;
    padding: 18px;
  }

  .detail-backdrop {
    position: fixed;
    inset: 0;
    z-index: 2;
    background: transparent;
    display: block;
  }

  .detail-drawer {
    position: sticky;
    top: 28px;
    z-index: 3;
    max-height: calc(100vh - 56px);
    overflow: auto;
  }

  .detail-title {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
  }

  .detail-heading {
    display: flex;
    align-items: flex-start;
    min-width: 0;
    gap: 14px;
  }

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

  .edit-button {
    flex: 0 0 auto;
  }

  .detail-actions {
    display: flex;
    flex: 0 0 auto;
    gap: 8px;
  }

  .meta-line {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
  }

  .cover-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 10px;
  }

  .cover-action {
    border: 1px solid var(--line);
    border-radius: 999px;
    background: #fff;
    color: var(--accent);
    padding: 6px 10px;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
  }

  .cover-action:disabled {
    opacity: .55;
    cursor: wait;
  }

  .pill {
    border-radius: 999px;
    background: #f0f4f5;
    color: #5d564b;
    padding: 6px 10px;
    font-size: 13px;
  }

  .person-link {
    border: 0;
    background: var(--accent-soft);
    color: var(--accent);
    cursor: pointer;
  }

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

  .read-grid {
    display: grid;
    grid-template-columns: repeat(12, minmax(0, 1fr));
    gap: 12px;
    align-items: start;
  }

  .read-field {
    display: grid;
    gap: 7px;
    min-width: 0;
    padding: 12px 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.76);
  }

  .read-field.compact {
    grid-column: span 3;
  }

  .read-field.medium {
    grid-column: span 6;
  }

  .read-field.long {
    grid-column: 1 / -1;
    background: #ffffff;
  }

  .read-field span {
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
  }

  .read-field div {
    color: var(--ink);
    font-size: 18px;
    line-height: 1.45;
    overflow-wrap: anywhere;
  }

  .read-field.compact div {
    font-size: 20px;
    font-weight: 700;
    line-height: 1.25;
  }

  .read-field.long div {
    font-size: 17px;
    line-height: 1.62;
  }

  .read-field em {
    color: var(--muted);
    font-style: normal;
  }

  .read-field blockquote {
    margin: 0 0 10px;
    padding: 13px 14px;
    border-left: 4px solid var(--rose);
    border-radius: 8px;
    background: #fff4ef;
    color: #5f403c;
  }

  .read-field blockquote:last-child {
    margin-bottom: 0;
  }

  .field.full {
    grid-column: 1 / -1;
  }

  textarea {
    min-height: 100px;
    resize: vertical;
    overflow: hidden;
  }

  .actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 16px;
  }

  .primary-button,
  .ghost-button,
  .danger-button,
  .icon-button {
    border: 1px solid var(--accent);
    border-radius: 8px;
    padding: 10px 13px;
    cursor: pointer;
  }

  .primary-button {
    background: var(--accent);
    color: white;
  }

  .ghost-button {
    background: white;
    color: var(--accent);
  }

  .danger-button {
    border-color: #d9aaa2;
    background: #fff4ef;
    color: #9e3f35;
  }

  .icon-button {
    display: grid;
    width: 42px;
    height: 42px;
    place-items: center;
    padding: 0;
    border-radius: 999px;
    background: white;
    color: var(--accent);
    font-size: 28px;
    line-height: 1;
  }

  .tag {
    display: inline-flex;
    align-items: center;
    margin: 0 6px 6px 0;
    padding: 6px 10px;
    border-radius: 999px;
    background: var(--accent-soft);
    color: var(--accent);
    font-size: 14px;
    font-weight: 700;
  }

  .tag-button,
  .tag-option,
  .tag-selected-item {
    border: 0;
    cursor: pointer;
  }

  .tag-selected {
    min-height: 36px;
  }

  .tag-add-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
  }

  .tag-options {
    display: flex;
    flex-wrap: wrap;
    gap: 0;
    max-height: 118px;
    overflow: auto;
    padding-top: 2px;
  }

  .alphabet-filter {
    display: flex;
    grid-column: 1 / -1;
    flex: 1 0 100%;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    margin-top: 2px;
    padding-top: 8px;
    border-top: 1px solid var(--line);
  }

  .alphabet-filter > span {
    margin-right: 4px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
  }

  .letter-button,
  .sort-header {
    border: 1px solid var(--line);
    background: white;
    color: var(--muted);
    cursor: pointer;
  }

  .letter-button {
    min-width: 34px;
    border-radius: 999px;
    padding: 7px 9px;
    font-size: 13px;
    font-weight: 800;
  }

  .letter-button[aria-pressed="true"],
  .sort-header[aria-pressed="true"] {
    border-color: var(--accent);
    background: var(--accent-soft);
    color: var(--accent);
  }

  .sort-header {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 6px;
    border-radius: 999px;
    font-size: inherit;
    font-weight: inherit;
    text-transform: inherit;
    letter-spacing: inherit;
  }

  .quote-appender {
    display: grid;
    gap: 10px;
  }

  .quote-draft {
    display: grid;
    gap: 6px;
    color: var(--muted);
    font-size: 12px;
  }

  .quote-editor-list {
    display: grid;
    gap: 12px;
  }

  .quote-editor-item {
    border: 1px solid var(--line);
    border-radius: 18px;
    background: #fff;
    padding: 12px;
  }

  .quote-editor-item textarea {
    min-height: 120px;
  }

  .quote-remove {
    justify-self: start;
    padding: 7px 12px;
  }

  .text-tools {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: -2px;
  }

  .text-tools button {
    border: 1px solid var(--line);
    border-radius: 999px;
    background: white;
    color: var(--accent);
    padding: 5px 9px;
    cursor: pointer;
    font-size: 13px;
  }

  .field-hint {
    margin-top: -2px;
    color: var(--muted);
    font-size: 12px;
  }

  .primary-button:disabled,
  .ghost-button:disabled,
  .danger-button:disabled {
    cursor: wait;
    opacity: 0.55;
  }

  .empty-state {
    display: grid;
    place-items: center;
    min-height: 360px;
    text-align: center;
    color: var(--muted);
  }

  .empty-state span {
    color: var(--ink);
    font-size: 22px;
    font-weight: 700;
  }

  .quote {
    margin-top: 14px;
    padding: 16px;
    border-left: 4px solid var(--rose);
    border-radius: 8px;
    background: #fff4ef;
    color: #5f403c;
    line-height: 1.55;
  }

  .related {
    margin-top: 18px;
    border-top: 1px solid var(--line);
    padding-top: 14px;
  }

  .related-list {
    display: grid;
    gap: 6px;
    margin-top: 8px;
  }

  .related-item {
    border: 0;
    border-radius: 8px;
    background: #eef4eb;
    color: var(--green);
    padding: 9px 10px;
    text-align: left;
    cursor: pointer;
  }

  .quotes-list {
    display: grid;
    gap: 10px;
  }

  .quote-source {
    position: sticky;
    top: 0;
    z-index: 1;
    margin: 0;
    padding: 16px 6px 6px;
    background: #ffffff;
    color: var(--ink);
    font-size: 20px;
  }

  .quote-row {
    width: 100%;
    border: 1px solid var(--row-border, transparent);
    border-radius: 8px;
    background: linear-gradient(90deg, var(--row-bg, #fff4ef), #ffffff);
    color: #5f403c;
    padding: 0;
    text-align: left;
    cursor: pointer;
    box-shadow: inset 4px 0 0 var(--row-accent, var(--rose));
  }

  .quote-row:hover {
    background: linear-gradient(90deg, var(--row-bg-hover, #ffece4), #ffffff);
    border-color: var(--accent);
  }

  .quote-row blockquote {
    margin: 0;
    padding: 14px 16px;
    border-left: 0;
    line-height: 1.55;
  }

  @media (max-width: 900px) {
    body {
      background: #ffffff;
    }

    body.detail-open {
      overflow: hidden;
      overscroll-behavior: none;
    }

    .app-shell {
      grid-template-columns: 1fr;
      display: block;
      padding-bottom: 116px;
    }

    .sidebar {
      position: fixed;
      left: 0;
      right: 0;
      bottom: 0;
      z-index: 20;
      padding: 8px 10px max(10px, env(safe-area-inset-bottom));
      border-top: 1px solid var(--line);
      border-right: 0;
      border-bottom: 0;
      background: #ffffff;
      box-shadow: 0 -12px 28px rgba(64, 50, 34, 0.16);
    }

    .brand {
      display: none;
    }

    .tabs {
      display: flex;
      overflow-x: auto;
      gap: 4px;
      justify-content: space-between;
      -webkit-overflow-scrolling: touch;
      scrollbar-width: none;
    }

    .tabs::-webkit-scrollbar {
      display: none;
    }

    .tab-button {
      display: grid;
      min-width: 54px;
      flex: 1 0 54px;
      justify-items: center;
      gap: 2px;
      padding: 7px 5px;
      border-radius: 13px;
      font-size: 10px;
      line-height: 1.1;
    }

    .tab-button span {
      display: grid;
      gap: 2px;
      justify-items: center;
    }

    .tab-button small {
      font-size: 9px;
    }

    .workspace {
      padding: max(12px, env(safe-area-inset-top)) 12px 112px;
    }

    .topbar {
      align-items: flex-start;
      gap: 10px;
      margin-bottom: 12px;
    }

    .topbar .ghost-button {
      padding: 8px 10px;
      border-radius: 12px;
      font-size: 13px;
    }

    h2 {
      font-size: 30px;
      line-height: 1.05;
    }

    .filters {
      position: static;
      z-index: 8;
      gap: 8px;
      padding: 10px;
      margin: 0 0 12px;
      border-radius: 18px;
      box-shadow: 0 10px 26px rgba(64, 50, 34, 0.08);
    }

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

    .content-grid.has-detail {
      grid-template-columns: 1fr;
    }

    .records {
      padding: 8px;
    }

    .records-table {
      display: grid;
      gap: 9px;
    }

    .records-header {
      display: none;
    }

    .record-row {
      display: grid;
      grid-template-columns: 44px minmax(0, 1fr) auto;
      gap: 10px;
      min-height: 76px;
      padding: 12px;
      border-radius: 16px;
      box-shadow: inset 4px 0 0 var(--row-accent, transparent), 0 8px 18px rgba(64, 50, 34, 0.06);
    }

    .record-row .record-cell {
      display: none;
    }

    .record-number {
      align-self: start;
      padding-top: 3px;
      font-size: 13px;
    }

    .record-title strong {
      font-size: 15px;
      line-height: 1.2;
      white-space: normal;
      display: -webkit-box;
      -webkit-line-clamp: 2;
      -webkit-box-orient: vertical;
    }

    .record-title small {
      font-size: 12px;
      line-height: 1.25;
      white-space: normal;
    }

    .record-title.with-cover {
      grid-template-columns: 48px minmax(0, 1fr);
      gap: 10px;
    }

    .album-cover-list {
      width: 48px;
      height: 48px;
      border-radius: 12px;
    }

    .record-score {
      align-self: start;
      min-width: 38px;
      padding: 5px 8px;
      border-radius: 999px;
      font-size: 13px;
    }

    .list-panel {
      border-radius: 18px;
      box-shadow: 0 12px 28px rgba(64, 50, 34, 0.08);
    }

    .panel-head {
      padding: 11px 12px;
    }

    .panel-head .primary-button {
      padding: 8px 10px;
      border-radius: 12px;
      font-size: 13px;
    }

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

    .read-field.compact,
    .read-field.medium,
    .read-field.long {
      grid-column: 1;
    }

    .detail-title {
      display: grid;
    }

    .detail-heading {
      display: grid;
      grid-template-columns: 82px minmax(0, 1fr);
      align-items: start;
      gap: 12px;
    }

    .album-cover-detail {
      width: 82px;
      height: 82px;
      border-radius: 16px;
    }

    .detail-drawer {
      position: fixed;
      inset: max(8px, env(safe-area-inset-top)) 8px max(8px, env(safe-area-inset-bottom));
      z-index: 40;
      max-height: calc(100vh - max(16px, env(safe-area-inset-top)) - max(16px, env(safe-area-inset-bottom)));
      padding: 14px;
      border-radius: 22px;
      overflow-y: auto;
      overscroll-behavior: contain;
      touch-action: pan-y;
      -webkit-overflow-scrolling: touch;
    }

    .detail-backdrop {
      display: block;
      z-index: 30;
      touch-action: none;
    }

    .detail-title h3 {
      font-size: 24px;
      line-height: 1.08;
    }

    .detail-actions {
      width: 100%;
      justify-content: flex-end;
    }

    .detail-actions .ghost-button,
    .detail-actions .danger-button {
      flex: 1;
    }

    .detail-actions .icon-button {
      flex: 0 0 46px;
    }

    .detail-actions .delete-button {
      flex: 0 0 52px;
    }

    .records {
      max-height: none;
    }

    .detail-panel {
      min-height: 0;
    }
  }