*,
    *::before,
    *::after {
      box-sizing: border-box;
      margin: 0;
      padding: 0;
    }

    :root {
      --bg: #FFFFFF;
      --text-primary: #1A1A1A;
      --text-secondary: #D1D1D1;
      --text-muted: #999999;
      --border: rgba(0,0,0,0.08);
      --accent: #566b00;
      --sidebar-w: 300px;
      --font-main: "Neue Haas Grotesk Display Pro", "Neue Haas Grotesk", "Inter", sans-serif;
    }

    html.dark {
      --bg: #1F1F1F;
      --text-primary: #E6E6E6;
      --text-muted: #666666;
      --border: rgba(255,255,255,0.07);
    }

    body {
      background: var(--bg);
      color: var(--text-primary);
      font-family: var(--font-main);
      -webkit-font-smoothing: antialiased;
      overflow: hidden;
      font-size: 14px;
    }

    .layout-wrapper {
      display: flex;
      height: 100vh;
      width: 100vw;
    }

    /* ─── MAIN CONTENT ─── */
    .scroll-container {
      flex: 1;
      margin-left: var(--sidebar-w);
      height: 100vh;
      overflow-y: auto;
      scroll-behavior: smooth;
    }

    main {
      display: flex;
      justify-content: center;
      padding: 80px 40px 120px 40px;
    }

    /* The scroll area starts after the fixed sidebar, so centring inside it
       lands half a sidebar right of the true screen centre. Pad the right by
       the sidebar width to pull the column back to the viewport centre — only
       once there is room for the full 540px column plus gutters. */
    @media (min-width: 1220px) {
      main {
        padding-right: calc(40px + var(--sidebar-w));
      }
    }

    .writing-container {
      max-width: 540px;
      width: 100%;
      display: flex;
      flex-direction: column;
      /* 56px + the first row's 8px of top padding puts the first title 64px
         below the header, matching .content-wrapper on library.html. */
      gap: 56px;
    }

    .back-btn-circular {
      width: 16px;
      height: 16px;
      border-radius: 50%;
      display: inline-flex;
      align-items: center;
      justify-content: center;
      transition: all 0.15s ease;
      background: transparent;
      color: var(--text-primary);
      text-decoration: none;
      border: none;
      cursor: pointer;
    }

    .back-btn-circular:hover {
      background: transparent;
      color: var(--accent);
    }

    .back-btn-circular:active {
      transform: scale(0.97);
    }

    .back-btn-circular svg {
      width: 16px;
      height: 16px;
    }

    /* ── PAGE HEADER ── */
    .page-header {
      padding: 0 0 4px;
    }

    .page-header h1 {
      font-size: 16px;
      font-weight: 500;
      color: var(--text-primary);
      margin-bottom: 4px;
      letter-spacing: -0.01em;
    }

    .page-header p {
      font-size: 14px;
      font-weight: 400;
      line-height: 1.6;
      color: var(--text-muted);
    }

    /* ── WRITING LIST ── */
    /* padding-left resets the 12px indent shared.css gives the nav dropdown of
       the same name, so the year column lines up with the page header. */
    .writing-container .writing-list {
      display: flex;
      flex-direction: column;
      padding-left: 0;
      padding-bottom: 80px;
    }

    /* Category label on the left, title takes the slack, date in a fixed
       right-hand column so dates stay aligned regardless of title length. */
    .writing-row {
      display: grid;
      grid-template-columns: 104px 1fr 64px;
      align-items: baseline;
      column-gap: 24px;
      padding: 8px 0;
      position: relative;
      text-decoration: none;
      color: inherit;
      transition: opacity 0.2s ease;
    }

    .writing-list:hover .writing-row {
      opacity: 0.4;
    }

    .writing-list:hover .writing-row:hover {
      opacity: 1;
    }

    /* Row dividers, parked until the list is long enough to need them. Rows
       within a section divide from the title column across; a row that opens a
       new section gets a full-width rule, so the groups read apart. Uncomment
       this and the matching block in the mobile query to bring them back —
       .starts-section is already on the rows that open a section. */
    /*
    .writing-row + .writing-row::before {
      content: "";
      position: absolute;
      top: 0;
      right: 0;
      left: calc(104px + 24px);
      height: 1px;
      background: var(--border);
    }

    .writing-row + .writing-row.starts-section::before {
      left: 0;
    }
    */

    /* The section labels its first row; later rows leave the cell empty so the
       column reads as one marker per section. */
    .writing-section {
      font-size: 14px;
      line-height: 1.35;
      color: var(--text-muted);
    }

    .writing-title {
      font-size: 14px;
      font-weight: 500;
      line-height: 1.35;
      color: var(--text-primary);
      transition: color 0.2s ease;
    }

    a.writing-row:hover .writing-title {
      color: var(--accent);
    }

    .writing-date {
      font-size: 14px;
      line-height: 1.35;
      color: var(--text-muted);
      text-align: right;
      white-space: nowrap;
    }

    /* Unpublished pieces are listed but greyed back, and are not links. */
    .writing-row.is-draft .writing-title,
    .writing-row.is-draft .writing-date {
      color: var(--text-muted);
      font-weight: 400;
    }

    .writing-draft {
      display: inline-block;
      margin-left: 8px;
      padding: 2px 8px;
      border: 1px solid var(--border);
      border-radius: 999px;
      font-size: 11px;
      font-weight: 400;
      letter-spacing: 0.06em;
      text-transform: uppercase;
      color: var(--text-muted);
      vertical-align: 1px;
    }

    @media (max-width: 767px) {
      /* Tighter section column and gutters; both labels still fit on one line. */
      .writing-row {
        grid-template-columns: 88px 1fr 56px;
        column-gap: 12px;
      }

      /*
      .writing-row + .writing-row::before {
        left: calc(88px + 12px);
      }
      */
    }
