/*!********************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************!*\
  !*** css ./node_modules/next/dist/build/webpack/loaders/css-loader/src/index.js??ruleSet[1].rules[15].oneOf[2].use[1]!./node_modules/next/dist/build/webpack/loaders/next-font-loader/index.js??ruleSet[1].rules[15].oneOf[2].use[2]!./node_modules/next/font/google/target.css?{"path":"src/app/layout.tsx","import":"Inter","arguments":[{"subsets":["latin"],"weight":["400","500","600"],"variable":"--font-inter","display":"swap"}],"variableName":"inter"} ***!
  \********************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************/
/* cyrillic-ext */
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url(/_next/static/media/ba9851c3c22cd980-s.woff2) format('woff2');
  unicode-range: U+0460-052F, U+1C80-1C8A, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F;
}
/* cyrillic */
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url(/_next/static/media/21350d82a1f187e9-s.woff2) format('woff2');
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
/* greek-ext */
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url(/_next/static/media/c5fe6dc8356a8c31-s.woff2) format('woff2');
  unicode-range: U+1F00-1FFF;
}
/* greek */
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url(/_next/static/media/19cfc7226ec3afaa-s.woff2) format('woff2');
  unicode-range: U+0370-0377, U+037A-037F, U+0384-038A, U+038C, U+038E-03A1, U+03A3-03FF;
}
/* vietnamese */
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url(/_next/static/media/df0a9ae256c0569c-s.woff2) format('woff2');
  unicode-range: U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169, U+01A0-01A1, U+01AF-01B0, U+0300-0301, U+0303-0304, U+0308-0309, U+0323, U+0329, U+1EA0-1EF9, U+20AB;
}
/* latin-ext */
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url(/_next/static/media/8e9860b6e62d6359-s.woff2) format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
/* latin */
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url(/_next/static/media/e4af272ccee01ff0-s.p.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
/* cyrillic-ext */
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url(/_next/static/media/ba9851c3c22cd980-s.woff2) format('woff2');
  unicode-range: U+0460-052F, U+1C80-1C8A, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F;
}
/* cyrillic */
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url(/_next/static/media/21350d82a1f187e9-s.woff2) format('woff2');
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
/* greek-ext */
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url(/_next/static/media/c5fe6dc8356a8c31-s.woff2) format('woff2');
  unicode-range: U+1F00-1FFF;
}
/* greek */
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url(/_next/static/media/19cfc7226ec3afaa-s.woff2) format('woff2');
  unicode-range: U+0370-0377, U+037A-037F, U+0384-038A, U+038C, U+038E-03A1, U+03A3-03FF;
}
/* vietnamese */
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url(/_next/static/media/df0a9ae256c0569c-s.woff2) format('woff2');
  unicode-range: U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169, U+01A0-01A1, U+01AF-01B0, U+0300-0301, U+0303-0304, U+0308-0309, U+0323, U+0329, U+1EA0-1EF9, U+20AB;
}
/* latin-ext */
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url(/_next/static/media/8e9860b6e62d6359-s.woff2) format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
/* latin */
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url(/_next/static/media/e4af272ccee01ff0-s.p.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
/* cyrillic-ext */
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url(/_next/static/media/ba9851c3c22cd980-s.woff2) format('woff2');
  unicode-range: U+0460-052F, U+1C80-1C8A, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F;
}
/* cyrillic */
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url(/_next/static/media/21350d82a1f187e9-s.woff2) format('woff2');
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
/* greek-ext */
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url(/_next/static/media/c5fe6dc8356a8c31-s.woff2) format('woff2');
  unicode-range: U+1F00-1FFF;
}
/* greek */
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url(/_next/static/media/19cfc7226ec3afaa-s.woff2) format('woff2');
  unicode-range: U+0370-0377, U+037A-037F, U+0384-038A, U+038C, U+038E-03A1, U+03A3-03FF;
}
/* vietnamese */
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url(/_next/static/media/df0a9ae256c0569c-s.woff2) format('woff2');
  unicode-range: U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169, U+01A0-01A1, U+01AF-01B0, U+0300-0301, U+0303-0304, U+0308-0309, U+0323, U+0329, U+1EA0-1EF9, U+20AB;
}
/* latin-ext */
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url(/_next/static/media/8e9860b6e62d6359-s.woff2) format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
/* latin */
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url(/_next/static/media/e4af272ccee01ff0-s.p.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}@font-face {font-family: 'Inter Fallback';src: local("Arial");ascent-override: 90.44%;descent-override: 22.52%;line-gap-override: 0.00%;size-adjust: 107.12%
}.__className_69d019 {font-family: 'Inter', 'Inter Fallback';font-style: normal
}.__variable_69d019 {--font-inter: 'Inter', 'Inter Fallback'
}

/*!**********************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************!*\
  !*** css ./node_modules/next/dist/build/webpack/loaders/css-loader/src/index.js??ruleSet[1].rules[15].oneOf[2].use[1]!./node_modules/next/dist/build/webpack/loaders/next-font-loader/index.js??ruleSet[1].rules[15].oneOf[2].use[2]!./node_modules/next/font/google/target.css?{"path":"src/app/layout.tsx","import":"Newsreader","arguments":[{"subsets":["latin"],"weight":"variable","style":["normal","italic"],"axes":["opsz"],"variable":"--font-newsreader","display":"swap"}],"variableName":"newsreader"} ***!
  \**********************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************/
/* vietnamese */
@font-face {
  font-family: 'Newsreader';
  font-style: italic;
  font-weight: 200 800;
  font-display: swap;
  src: url(/_next/static/media/fc61cfb200d549a5-s.woff2) format('woff2');
  unicode-range: U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169, U+01A0-01A1, U+01AF-01B0, U+0300-0301, U+0303-0304, U+0308-0309, U+0323, U+0329, U+1EA0-1EF9, U+20AB;
}
/* latin-ext */
@font-face {
  font-family: 'Newsreader';
  font-style: italic;
  font-weight: 200 800;
  font-display: swap;
  src: url(/_next/static/media/fe6c4b8cc116014d-s.woff2) format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
/* latin */
@font-face {
  font-family: 'Newsreader';
  font-style: italic;
  font-weight: 200 800;
  font-display: swap;
  src: url(/_next/static/media/8edf6d3506a17285-s.p.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
/* vietnamese */
@font-face {
  font-family: 'Newsreader';
  font-style: normal;
  font-weight: 200 800;
  font-display: swap;
  src: url(/_next/static/media/b5963afcf1479527-s.woff2) format('woff2');
  unicode-range: U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169, U+01A0-01A1, U+01AF-01B0, U+0300-0301, U+0303-0304, U+0308-0309, U+0323, U+0329, U+1EA0-1EF9, U+20AB;
}
/* latin-ext */
@font-face {
  font-family: 'Newsreader';
  font-style: normal;
  font-weight: 200 800;
  font-display: swap;
  src: url(/_next/static/media/5ed7d4ff5e59016d-s.woff2) format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
/* latin */
@font-face {
  font-family: 'Newsreader';
  font-style: normal;
  font-weight: 200 800;
  font-display: swap;
  src: url(/_next/static/media/84adbee2f2a7cb50-s.p.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}@font-face {font-family: 'Newsreader Fallback';src: local("Times New Roman");ascent-override: 69.68%;descent-override: 25.12%;line-gap-override: 0.00%;size-adjust: 105.48%
}.__className_a4d3ee {font-family: 'Newsreader', 'Newsreader Fallback'
}.__variable_a4d3ee {--font-newsreader: 'Newsreader', 'Newsreader Fallback'
}

/*!*******************************************************************************************************************************************************************************************************************************************************************!*\
  !*** css ./node_modules/next/dist/build/webpack/loaders/css-loader/src/index.js??ruleSet[1].rules[15].oneOf[10].use[2]!./node_modules/next/dist/build/webpack/loaders/postcss-loader/src/index.js??ruleSet[1].rules[15].oneOf[10].use[3]!./src/styles/tokens.css ***!
  \*******************************************************************************************************************************************************************************************************************************************************************/
/* Design Tokens: Single Source of Truth for Typography Tiers, Spacing, and Semantic Colors
   CHG-5601: Site-wide design tokens infrastructure

   This file defines all reusable design tokens consumed by tier classes and components.
   Changing a token here updates every component that uses it via CSS variables.
*/

:root {
  /* ============================================================================
     TYPOGRAPHY TOKENS (per tier)
     ============================================================================
     Each tier has: size, weight, tracking (letter-spacing in px), case, family, color
  */

  /* Display tier: Newsreader 40/600/-0.2px, --text-primary. Dashboard hero only. */
  --type-display-size: 40px;
  --type-display-weight: 600;
  --type-display-tracking: -0.2px;
  --type-display-case: none;
  --type-display-family: var(--font-newsreader), Georgia, 'Times New Roman', serif;
  --type-display-color: var(--text-primary);

  /* Title tier: Newsreader 24/600/-0.1px, --text-primary. Page and modal titles. */
  --type-title-size: 24px;
  --type-title-weight: 600;
  --type-title-tracking: -0.1px;
  --type-title-case: none;
  --type-title-family: var(--font-newsreader), Georgia, 'Times New Roman', serif;
  --type-title-color: var(--text-primary);

  /* Heading tier: Newsreader 16/600, --text-primary. Standalone card/modal titles only. */
  --type-heading-size: 16px;
  --type-heading-weight: 600;
  --type-heading-tracking: 0;
  --type-heading-case: none;
  --type-heading-family: var(--font-newsreader), Georgia, 'Times New Roman', serif;
  --type-heading-color: var(--text-primary);

  /* Label tier: Inter 10/600/1.5px/UPPERCASE, --text-secondary. Section headings within tabs/panels.
     CHG-6229: size converted px->rem (0.625rem == 10px at the default 16px root
     font-size, so desktop is pixel-identical) so the OS/browser "larger text"
     setting can rescale it — see the mobile override block at the end of this
     file for the >=768px-and-under floor. */
  --type-label-size: 0.625rem;
  --type-label-weight: 600;
  --type-label-tracking: 1.5px;
  --type-label-case: uppercase;
  --type-label-family: var(--font-inter), -apple-system, 'Segoe UI', system-ui, sans-serif;
  --type-label-color: var(--text-secondary);

  /* Action tier: Inter 10/600/1px/UPPERCASE. Buttons (primary, secondary, danger).
     CHG-6229: size converted px->rem (0.625rem == 10px), see note above .type-label-size. */
  --type-action-size: 0.625rem;
  --type-action-weight: 600;
  --type-action-tracking: 1px;
  --type-action-case: uppercase;
  --type-action-family: var(--font-inter), -apple-system, 'Segoe UI', system-ui, sans-serif;
  --type-action-color: inherit; /* Context-dependent: primary = white on accent, secondary = --text-secondary, danger = --error */

  /* Badge tier: Inter 9/600/0.5px/UPPERCASE, white. Status labels on colored backgrounds.
     CHG-6229: size converted px->rem (0.5625rem == 9px), see note above .type-label-size. */
  --type-badge-size: 0.5625rem;
  --type-badge-weight: 600;
  --type-badge-tracking: 0.5px;
  --type-badge-case: uppercase;
  --type-badge-family: var(--font-inter), -apple-system, 'Segoe UI', system-ui, sans-serif;
  --type-badge-color: white;

  /* Prose tier: Newsreader 15/400/1.6, --text-primary. Critique findings, summaries. */
  --type-prose-size: 15px;
  --type-prose-weight: 400;
  --type-prose-tracking: 0;
  --type-prose-case: none;
  --type-prose-family: var(--font-newsreader), Georgia, 'Times New Roman', serif;
  --type-prose-color: var(--text-primary);

  /* UI tier: Inter 12/400/1.5, --text-primary. General body text, form fields.
     CHG-6229: size converted px->rem (0.75rem == 12px), see note above .type-label-size. */
  --type-ui-size: 0.75rem;
  --type-ui-weight: 400;
  --type-ui-tracking: 0;
  --type-ui-case: none;
  --type-ui-family: var(--font-inter), -apple-system, 'Segoe UI', system-ui, sans-serif;
  --type-ui-color: var(--text-primary);

  /* Meta tier: Inter 11/400, --text-muted. Fine print, empty states.
     CHG-6229: size converted px->rem (0.6875rem == 11px), see note above .type-label-size. */
  --type-meta-size: 0.6875rem;
  --type-meta-weight: 400;
  --type-meta-tracking: 0;
  --type-meta-case: none;
  --type-meta-family: var(--font-inter), -apple-system, 'Segoe UI', system-ui, sans-serif;
  --type-meta-color: var(--text-muted);

  /* Metric tier: Newsreader 32/600, --color-metric. Large score displays. */
  --type-metric-size: 32px;
  --type-metric-weight: 600;
  --type-metric-tracking: 0;
  --type-metric-case: none;
  --type-metric-family: var(--font-newsreader), Georgia, 'Times New Roman', serif;
  --type-metric-color: var(--color-metric);

  /* ============================================================================
     SPACING TOKENS (4px scale)
     ============================================================================
     Used for padding, margin, gap. Multiples of 4px for consistent rhythm.
  */

  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-7: 28px;
  --space-8: 32px;

  /* ============================================================================
     ICON SIZE TOKENS (CHG-5690)
     ============================================================================
     Icon sizing for inline SVG glyphs. Based on --space-* scale for consistency.
  */

  --icon-size-sm: 14px;  /* Inline icons within prose/actions */
  --icon-size-md: 16px;  /* Standard tree/button icons */
  --icon-size-lg: 20px;  /* Prominent hero actions */

  /* ============================================================================
     TOUCH TARGET TOKENS (CHG-6229)
     ============================================================================
     Before this change, every tappable control that needed a minimum hit area
     (mobile bottom nav, scene-switcher move/delete buttons, etc.) hand-typed its
     own "44px" literal — no shared token existed. These two tokens are the
     single source of truth going forward:
  */

  /* Standard mobile tap-target floor (Material/WCAG 2.5.5 baseline). Use for
     any ordinary tappable control on mobile — buttons, icon buttons, list-row
     tap areas. Supersedes the old ad-hoc "44px" literals (being migrated to
     this token one component at a time; see docs/GLOSSARY.md). */
  --touch-target-min: 48px;

  /* Larger "emphasis control" floor for high-stakes/primary actions that
     deserve an even bigger target than the standard minimum. Defined by
     CHG-6229 but NOT yet consumed by any component in that change -- it
     exists so the forthcoming mobile nav-rework change's "resequence mode"
     large reorder buttons have a single number to build on instead of
     inventing their own. */
  --touch-target-generous: 64px;

  /* ============================================================================
     SEMANTIC COLOR TOKENS (aliases to existing palette)
     ============================================================================
     Semantic names for common uses. All reference existing --accent, --error, etc.
  */

  --color-metric: var(--accent); /* Score displays, important metrics. */
  --color-info-bg: var(--accent-light); /* Info box backgrounds. */
  --color-info-border: var(--accent-fixed-dim); /* Info box borders. */
  --color-danger: var(--error); /* Danger/error text. */
  --color-danger-bg: var(--error-container); /* Danger box backgrounds. */
  --success-light: rgba(79, 96, 81, 0.12); /* CHG-5841: success message-box background. Mirrors --accent-light's rgba-overlay-on-brand-color pattern, overlaid on --success (#4f6051). */

  /* Badge status colors (CHG-5616) */
  --badge-success-bg: #4f6051; /* Emerald background for high-scoring badges */
  --badge-success-text: white;
  --badge-success-border: #3d4a3f;
  --badge-warning-bg: #a67c52; /* Warm amber/brown for medium-scoring badges */
  --badge-warning-text: white;
  --badge-warning-border: #8b6847;
  --badge-error-bg: #ba1a1a; /* Red background for low-scoring badges */
  --badge-error-text: white;
  --badge-error-border: #931111;

  /* Status color tokens — success, warning, error states (CHG-5617)
     Use Material Design palette vars for dark mode support. */
  --status-success: var(--success); /* Success/positive status: Material Design success color */
  --status-success-light: #c8e6c9; /* Light green: success variant */
  --status-warning: #f57c00; /* Warning/intermediate status: warm orange */
  --status-warning-alt: #e8b74d; /* Alternate warning: warm golden amber */
  --status-error: var(--error); /* Error/negative status: Material Design error color */
  --status-error-dark: #b71c1c; /* Darker error/danger state */

  /* Category palette — semantic colors for specific UI domains (CHG-5615/5616) */
  --category-memory: #a67c52; /* Memories tab character color (warm amber) */
  --category-campaign: #a67c52; /* Marketing campaign cards theme (warm amber) */
  --category-style: #c97c3c; /* Memories style category (warm rust, not purple) */

  /* Category colors — distinct semantic colors for UI domains (CHG-5617)
     Used in card rendering and category badges. Warm, distinct, readable values. */
  --category-social: #8b7355; /* Social media category: warm brown */
  --category-review: #c97c3c; /* Review/feedback category: warm rust */
  --category-promotion: #d85d5d; /* Promotional category: warm muted red */
  --category-plot: #a67c52; /* Plot-related content: warm amber */
  --category-world: #6b8e23; /* World/setting content: warm olive */

  /* Storyboard category colours — 8 distinct hues for grouping strategies (CHG-5688)
     Used for narrator, strand, act, chapter, cast, artifact legend entries and scene card borders.
     Light and dark mode pairs ensure readability on both card backgrounds. */
  --storyboard-cat-1: #5B8DEF; /* Blue: primary, calm */
  --storyboard-cat-2: #E8764D; /* Coral: warm accent */
  --storyboard-cat-3: #6BC9A0; /* Sage: fresh, balanced */
  --storyboard-cat-4: #C77DBA; /* Mauve: purple-pink */
  --storyboard-cat-5: #E6C04E; /* Gold: warm highlight */
  --storyboard-cat-6: #4ECDC4; /* Teal: cool contrast */
  --storyboard-cat-7: #F27979; /* Rose: soft red */
  --storyboard-cat-8: #7B8CDE; /* Periwinkle: light purple */

  /* Quality band colours (CHG-5871) — one discrete colour per canonical rubric
     band (DEFAULT_BANDS in rubric-model.ts), used by the Quality tab's score
     roundels. A 6-step red->green gradient, plus a neutral grey for scores
     that have no band (unscored, or an admin-renamed/unrecognised band
     label) — grey is deliberately distinct from "low score" red so it isn't
     misread as a bad score. */
  --quality-band-draft: #ba1a1a; /* reuses --status-error-dark's red */
  --quality-band-developing: #c9712e; /* warm orange */
  --quality-band-competent: #a67c52; /* reuses --badge-warning-bg's amber/brown */
  --quality-band-strong: #8fa33e; /* yellow-green */
  /* CHG-5871 code review: professional/exceptional originally reused --success
     (#4f6051), a muted/desaturated green designed for subtle UI chrome — on a
     roundel it read as darker and less vivid than "strong" right before it,
     breaking the "at-a-glance" red->green progression the spec calls for.
     Replaced with two properly-ordered vivid greens instead of reusing that token. */
  --quality-band-professional: #3f8f54; /* vivid medium green */
  --quality-band-exceptional: #1f9e42; /* vivid brighter green */
  --quality-band-unscored: #8a8f98; /* neutral grey, ~ --text-muted */
}

/* ============================================================================
   MOBILE TYPOGRAPHY OVERRIDE (CHG-6229)
   ============================================================================
   Foundational legibility fix: on screens <=768px (same breakpoint
   globals.css's own "Mobile adjustments" block already uses), the small
   reading/UI tiers get a generous floor instead of their desktop px-converted
   values above. Desktop is completely unaffected -- this block only applies
   under the media query. Scoped to the tiers that render actual body/label/UI
   copy; --type-display/-title/-heading/-prose/-metric are already >=15px and
   are not touched here.
*/
@media (max-width: 768px) {
  :root {
    --type-label-size: 1rem;    /* 16px, up from 10px */
    --type-action-size: 1rem;   /* 16px, up from 10px */
    --type-ui-size: 1rem;       /* 16px, up from 12px */
    --type-meta-size: 1rem;     /* 16px, up from 11px */
    /* Smaller bump than the other four: badges are compact status pills, not
       reading copy -- still a 55% increase over the desktop 9px. */
    --type-badge-size: 0.875rem; /* 14px, up from 9px */
  }
}

/*!*****************************************************************************************************************************************************************************************************************************************************************!*\
  !*** css ./node_modules/next/dist/build/webpack/loaders/css-loader/src/index.js??ruleSet[1].rules[15].oneOf[10].use[2]!./node_modules/next/dist/build/webpack/loaders/postcss-loader/src/index.js??ruleSet[1].rules[15].oneOf[10].use[3]!./src/app/globals.css ***!
  \*****************************************************************************************************************************************************************************************************************************************************************/
:root {
  /* Surface hierarchy */
  --bg-primary: #fbf9f6;
  --bg-secondary: #eae8e5;
  --bg-surface: #ffffff;
  --bg-surface-low: #f5f3f0;
  --bg-surface-container: #efeeeb;
  --border: #d2c4b9;
  --border-subtle: #e4e2df;

  /* Text hierarchy */
  --text-primary: #1b1c1a;
  --text-secondary: #4f453c;
  --text-muted: #81756b;

  /* Accent / Primary */
  --accent: #73573a;
  --accent-hover: #5b4226;
  --accent-container: #8d6f50;
  --accent-light: rgba(115, 87, 58, 0.08);
  --accent-fixed: #ffdcbc;
  --accent-fixed-dim: #e5c09c;

  /* Tertiary (AI / green) */
  --tertiary: #4f6051;
  --tertiary-container: #677968;
  --tertiary-fixed: #d4e8d4;
  --tertiary-fixed-dim: #b8ccb8;

  /* Chat */
  --chat-user-bg: #8d6f50;
  --chat-user-text: #fffbff;
  --chat-ai-bg: #d4e8d4;
  --chat-ai-text: #0f1f13;

  /* Secondary */
  --secondary: #655d56;
  --secondary-fixed: #ece0d8;

  /* Status */
  --error: #ba1a1a;
  --error-container: #ffdad6;
  --success: #4f6051;

  /* Elevation */
  --shadow-sm: 0 1px 3px rgba(27, 28, 26, 0.05);
  --shadow-md: 0 4px 12px rgba(27, 28, 26, 0.08);
  --shadow-lg: 0 10px 30px rgba(61, 50, 41, 0.06);
  --shadow-xl: 0 16px 48px rgba(61, 50, 41, 0.12);

  /* Radii */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 20px;

  --transition: 0.2s ease;
  /* CHG-4899: dedicated duration for the Structure tab's expand/collapse
     concertina animation (see .expand-collapse-transition below) — deliberately
     decoupled from the app-wide --transition so tuning one never affects the
     other. */
  --transition-collapse: 0.4s ease;
}

/* Site-wide reset — margin/padding/box-sizing only
   CHG-5601: Establishes box model baseline without affecting form control inheritance. */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/* Form control inheritance — font and color only
   CHG-5601: Allows form elements to inherit typography from their containers. */
button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

body {
  font-family: var(--font-inter), -apple-system, 'Segoe UI', system-ui, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Prose text in the editor */
.prose-editor {
  font-family: var(--font-newsreader), Georgia, 'Times New Roman', serif;
  font-size: 18px;
  line-height: 1.8;
  color: var(--text-primary);
  letter-spacing: 0.01em;
}

.prose-editor p {
  margin-bottom: 1.1em;
}

/* CHG-5950: figure-token-extension.ts's live figure-reference decoration --
   hides the raw ⟦fig:<figureId>⟧ sentinel text and shows a resolved widget
   in its place. CHG-6000: the widget is now a clickable image thumbnail
   (.figure-token-thumb) instead of a "Figure N" / "Figure N: Title" text
   pill -- the resolved label survives as the thumbnail's native `title`
   tooltip instead (see figure-token-extension.ts). */
.figure-token-hidden {
  display: none;
}

.figure-token-thumb {
  width: 64px;
  height: 64px;
  object-fit: cover;
  border-radius: 4px;
  border: 1px solid var(--border-subtle);
  cursor: pointer;
  /* CHG-6009: enlarged from 28px to 64px (matches figures-tab.tsx's own
     figure thumbnails -- one consistent "figure thumbnail" size app-wide).
     .prose-editor's line-height (1.8 * 18px ~= 32.4px) no longer exceeds
     this, so the text line visibly grows taller wherever a thumbnail
     appears -- that's the intended "noticeably larger" effect, not a
     regression. vertical-align: middle still keeps it baseline-centered
     on the (now taller) line. */
  vertical-align: middle;
  display: inline-block;
}

/* CHG-6009: the plain-text thumbnail (figure-token-extension.ts's second
   decoration pass) sits immediately after visible text instead of
   replacing hidden text like the live-token thumbnail does, so it needs a
   small gap to avoid visually colliding with the closing ')'. */
.figure-token-thumb--plain {
  margin-left: 6px;
}

/* Labels and tab text */
.label {
  font-family: var(--font-inter), -apple-system, system-ui, sans-serif;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--text-secondary);
  font-weight: 600;
}

/* Headings */
h1, h2, h3 {
  font-family: var(--font-newsreader), Georgia, 'Times New Roman', serif;
  color: var(--text-primary);
  font-weight: 600;
  letter-spacing: -0.01em;
}

/* CHG-5048: assistant chat message markdown content spacing. Global
   *{margin:0;padding:0} reset strips default block spacing, so markdown block
   elements need it added back explicitly here, scoped to assistant bubbles
   only (user bubbles stay plain text, see chat-message.tsx). Headings also
   need font-family/color reset back to the chat's sans-serif since the global
   `h1, h2, h3` rule above switches them to the serif brand font otherwise. */
.chat-markdown { overflow-wrap: anywhere; }
.chat-markdown p { margin-bottom: 0.5em; }
.chat-markdown p:last-child { margin-bottom: 0; }
.chat-markdown ul, .chat-markdown ol { margin: 0.4em 0 0.6em 1.3em; }
.chat-markdown li { margin-bottom: 0.2em; }
.chat-markdown li:last-child { margin-bottom: 0; }
.chat-markdown h1, .chat-markdown h2, .chat-markdown h3,
.chat-markdown h4, .chat-markdown h5, .chat-markdown h6 {
  margin: 0.5em 0 0.3em;
  font-size: 1.05em;
  font-weight: 600;
  font-family: inherit;
  color: inherit;
  letter-spacing: normal;
}
.chat-markdown h1:first-child, .chat-markdown h2:first-child, .chat-markdown h3:first-child,
.chat-markdown h4:first-child, .chat-markdown h5:first-child, .chat-markdown h6:first-child { margin-top: 0; }
.chat-markdown blockquote {
  margin: 0.4em 0;
  padding-left: 10px;
  border-left: 2px solid var(--border);
  color: inherit;
  opacity: 0.85;
}
.chat-markdown table {
  border-collapse: collapse;
  margin: 0.4em 0;
  font-size: 0.9em;
  max-width: 100%;
  display: block;
  overflow-x: auto;
}
.chat-markdown th, .chat-markdown td {
  border: 1px solid var(--border-subtle);
  padding: 4px 8px;
}

/* Dooler brand mark */
.brand {
  font-family: var(--font-newsreader), Georgia, serif;
  font-style: italic;
  color: var(--accent);
}

/* Buttons — adopt action tier (CHG-5601)
   All buttons now use the action tier consistently: Inter 10/600/UPPERCASE/1px.
   Variant classes (.btn-primary, .btn-danger, .btn-ghost) override background/border.
   This single update changes every button on the site. */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-surface);
  color: var(--text-primary);
  cursor: pointer;
  font-family: var(--type-action-family);
  font-size: var(--type-action-size);
  font-weight: var(--type-action-weight);
  letter-spacing: var(--type-action-tracking);
  text-transform: var(--type-action-case);
  transition: all var(--transition);
  box-shadow: var(--shadow-sm);
  position: relative;
  white-space: nowrap;
}

.btn:hover {
  background: var(--bg-surface-low);
  box-shadow: var(--shadow-md);
  transform: translateY(-0.5px);
}

/* CHG-5754: ProfileMenu items — hover/keyboard-focus highlight. */
.profile-menu-item:hover,
.profile-menu-item:focus-visible {
  background: var(--bg-surface-low) !important;
}

.btn:active {
  transform: translateY(0);
  box-shadow: inset 0 1px 3px rgba(27, 28, 26, 0.1);
  background: var(--bg-secondary);
}

.btn:disabled {
  opacity: 0.5;
  cursor: default;
  box-shadow: none;
  transform: none;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-container) 100%);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 2px 8px rgba(115, 87, 58, 0.25);
  /* Inherits action tier text styling (font/size/weight/tracking/case) from .btn */
}

.btn-primary:hover {
  background: linear-gradient(135deg, var(--accent-hover) 0%, var(--accent) 100%);
  color: #fff;
  box-shadow: 0 4px 16px rgba(115, 87, 58, 0.3);
  transform: translateY(-0.5px);
}

.btn-primary:active {
  background: linear-gradient(135deg, var(--accent-hover) 0%, var(--accent-hover) 100%);
  color: #fff;
  transform: scale(0.98);
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.2);
}

.btn-danger {
  color: var(--error);
  border-color: rgba(186, 26, 26, 0.2);
}

.btn-danger:hover {
  background: var(--error-container);
  border-color: rgba(186, 26, 26, 0.3);
}

.btn-ghost {
  background: transparent;
  border-color: transparent;
  box-shadow: none;
}

.btn-ghost:hover {
  background: var(--accent-light);
  box-shadow: none;
}

/* CHG-6211: Decision resolution-option buttons (DecisionRow in
   improvement-plan-section.tsx) render a variable-length label plus an
   optional rationale span as two children of a `.btn` — but `.btn` is
   `display: inline-flex` with an explicit `white-space: nowrap` (shared by
   every button site-wide, see the comment above .btn), so long option text
   was overflowing past the card's right edge instead of wrapping. Scoped
   here rather than editing `.btn` itself, since most other buttons rely on
   its nowrap/inline-flex sizing (e.g. single short action labels) and a
   global change would risk regressing them.
   Cascade note: `.btn`, `.btn-ghost`, and `.decision-option-btn` are all
   single-class selectors (equal specificity, 0-1-0) — this rule must stay
   appended AFTER `.btn`/`.btn-ghost` in source order for its `display`/
   `white-space` overrides to win; it does not rely on `!important`. */
.decision-option-btn {
  display: block;
  width: 100%;
  white-space: normal;
  overflow-wrap: break-word;
}

/* Inputs */
.input {
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  color: var(--text-primary);
  font-family: var(--font-inter), -apple-system, system-ui, sans-serif;
  font-size: 14px;
  width: 100%;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
}

.input::placeholder {
  color: var(--text-muted);
  opacity: 0.6;
}

select.input {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%234f453c' d='M3 5l3 3 3-3'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}

/* Thinking indicator */
.thinking-dots::after {
  content: '';
  animation: dots 1.5s steps(4, end) infinite;
}

@keyframes dots {
  0% { content: ''; }
  25% { content: '.'; }
  50% { content: '..'; }
  75% { content: '...'; }
}

/* Entity links - clickable author, series, book names */
.entity-link {
  color: var(--accent);
  text-decoration: none;
  transition: color var(--transition);
  font-weight: 500;
}

.entity-link:hover {
  color: var(--accent-hover);
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-thickness: 1px;
}

/* CHG-4892/CHG-4899: Structure tab Act/Chapter concertina expand/collapse
   animation. Uses its own --transition-collapse duration (see :root above),
   deliberately decoupled from the app-wide --transition so this animation can
   be tuned independently of unrelated UI (buttons, inputs, cards, etc).
   Duration MUST stay in sync with COLLAPSE_MS in structure-tab.tsx's
   AnimatedCollapse helper (currently 400ms == var(--transition-collapse)'s
   0.4s). This is a manual sync, not read programmatically — if
   --transition-collapse ever changes, grep for COLLAPSE_MS alongside it. */
.expand-collapse-transition {
  transition: grid-template-rows var(--transition-collapse), opacity var(--transition-collapse);
}

/* Gives the expand direction something to animate FROM: without this, a newly
   mounted (just-expanded) element renders straight at its final open state
   with nothing to transition from, so only the collapse direction would
   visibly animate. Progressive enhancement — unsupported browsers just skip
   the entrance animation and render open immediately, which is a fine,
   non-breaking degradation. */
@starting-style {
  .expand-collapse-transition {
    grid-template-rows: 0fr;
    opacity: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .expand-collapse-transition {
    transition: none;
  }
}

/* Cards */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 24px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition);
}

.card:hover {
  box-shadow: var(--shadow-md);
}

/* Modal overlay */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(27, 28, 26, 0.35);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  animation: fadeIn 0.15s ease;
}

.modal {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 28px;
  width: 100%;
  max-width: 480px;
  max-height: calc(100dvh - 48px);
  overflow-y: auto;
  box-shadow: var(--shadow-xl);
  animation: slideUp 0.2s ease;
  /* CHG-6240: defensive no-op today -- blocks the flex shrink-to-fit
     min-width:auto footgun from resurfacing if overflow-y above is ever
     changed. See CHG-6240's ticket/commit for the full investigation. */
  min-width: 0;
}

.modal--wide {
  max-width: 720px;
}

/* CHG-5841: extra-wide variant for the tabbed character editor modal —
   tabbed content plus the new "appears in" scene list needs more room
   than .modal--wide's 720px. */
.modal--xwide {
  max-width: 880px;
}

.modal-actions {
  display: flex;
  gap: var(--space-3);
  position: sticky;
  bottom: -28px;
  margin: 0 -28px -28px -28px;
  padding: 16px 28px 28px 28px;
  background: var(--bg-surface);
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* CHG-4913: CSS-only tooltip bubble for any element with a data-tooltip
   attribute (paired with the tooltip() helper in src/lib/tooltip.ts, which also
   sets title + aria-label on the same element). Shown on :hover AND
   :focus-visible so sighted keyboard users (who never trigger :hover, and whom
   the native title attribute does not show a tooltip for on focus) get the
   same description as mouse users; aria-label covers screen readers. */
[data-tooltip] {
  position: relative;
}

[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%) translateY(2px);
  background: var(--text-primary);
  color: var(--bg-surface);
  font-size: 11px;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  /* CHG-4917: some tooltip copy (disabled-reason strings and several static
     enabled-state strings) runs well past the ~60-char assumption this rule
     was originally built on, so it must wrap within a constrained width
     instead of clipping/overflowing as a single un-wrapped line. The
     calc(100vw - 32px) clamp additionally guarantees the bubble itself is
     never wider than the viewport on narrow/mobile screens. */
  max-width: min(240px, calc(100vw - 32px));
  white-space: normal;
  overflow-wrap: break-word;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease, transform 0.15s ease;
  z-index: 200;
}

[data-tooltip]:hover::after,
[data-tooltip]:focus-visible::after {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* CHG-4917: opt-in edge-safe alignment for tooltip anchors near a screen edge
   (e.g. the first/last control in a full-width toolbar) — see tooltip.ts's
   `align` param. Overrides the default centered translateX(-50%) positioning
   above, since centering a wrapped, wider bubble on an edge-anchored control
   can push it off-screen. */
[data-tooltip][data-tooltip-align="start"]::after {
  left: 0;
  transform: translateY(2px);
}

[data-tooltip][data-tooltip-align="start"]:hover::after,
[data-tooltip][data-tooltip-align="start"]:focus-visible::after {
  transform: translateY(0);
}

[data-tooltip][data-tooltip-align="end"]::after {
  left: auto;
  right: 0;
  transform: translateY(2px);
}

[data-tooltip][data-tooltip-align="end"]:hover::after,
[data-tooltip][data-tooltip-align="end"]:focus-visible::after {
  transform: translateY(0);
}

@media (prefers-reduced-motion: reduce) {
  [data-tooltip]::after {
    transition: none;
  }
}

/* Scrollbar styling */
::-webkit-scrollbar {
  width: 4px;
  height: 4px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* Selection color */
::selection {
  background: var(--accent-fixed-dim);
  color: var(--accent-hover);
}

/* CHG-5069: Book Info tab's Genre/Period row — two equal-width flex columns
   on wide layouts, stacked below the mobile breakpoint so each field has
   room for its label + Regenerate/Reset/View reasoning buttons (see
   generated-field.tsx's flexWrap fix alongside this for the same bug). */
.book-info-genre-period-row {
  display: flex;
  gap: 12px;
}

/* Mobile adjustments */
@media (max-width: 768px) {
  /* CHG-6229: inherited/untiered text (anything that doesn't use a .t-*
     tier class or an explicit font-size) also clears the new mobile
     legibility floor. */
  body {
    font-size: 16px;
  }

  .book-info-genre-period-row {
    flex-direction: column;
  }

  .prose-editor {
    font-size: 16px;
    line-height: 1.7;
  }

  .modal {
    margin: 12px;
    max-width: calc(100% - 24px);
    max-height: calc(100dvh - 24px);
    overflow-y: auto;
  }

  .input {
    font-size: 16px; /* Prevents iOS zoom on focus */
  }

  /* Dashboard mobile */
  .dashboard {
    padding: 24px 16px !important;
  }

  .dashboard h1 {
    font-size: 28px !important;
  }

  .dashboard h2 {
    font-size: 22px !important;
  }

  .dashboard h3 {
    font-size: 17px !important;
  }

  .dashboard .card {
    padding: 16px !important;
  }

  .dashboard .book-row {
    padding: 10px 8px !important;
  }

  .dashboard form {
    flex-direction: column !important;
  }

  .dashboard form .btn {
    align-self: stretch;
  }
}

/* CHG-5046 Step 4: BottomSheet — generic half/full-detent sheet used by
   SceneSwitcherSheet and MobileSearchSheet (CHG-6258: AiSheet, the original
   other consumer, was deleted). Backdrop + sheet are siblings (not nested)
   so the sheet's own z-index can sit above the backdrop without needing a
   portal. */
.bottom-sheet-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(27, 28, 26, 0.35);
  z-index: 40;
  animation: bottom-sheet-fade-in 0.2s ease;
}

.bottom-sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 41;
  display: flex;
  flex-direction: column;
  background: var(--bg-surface);
  border-top-left-radius: var(--radius-lg);
  border-top-right-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  overflow: hidden;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

.bottom-sheet-handle {
  flex-shrink: 0;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: grab;
  touch-action: none;
}

.bottom-sheet-handle:active {
  cursor: grabbing;
}

.bottom-sheet-handle-bar {
  width: 36px;
  height: 4px;
  border-radius: 2px;
  background: var(--border);
}

.bottom-sheet-content {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  touch-action: pan-y;
}

@keyframes bottom-sheet-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* CHG-5046 Step 5: DisabledHint — tap-to-reveal mobile alternative to
   tooltip()'s hover bubble. */
.disabled-hint {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.disabled-hint-trigger {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1;
  padding: 4px;
  /* 44pt minimum touch target, same floor as every other new mobile
     control in this change. */
  min-width: 44px;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* CHG-5046 Step 7: SelectionToolbar — floating format toolbar positioned via
   editor.view.coordsAtPos, clamped above the on-screen keyboard. */
.selection-toolbar {
  position: fixed;
  z-index: 30;
  display: flex;
  gap: 2px;
  background: var(--text-primary);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  padding: 4px;
  transform: translateX(-8px);
}

.selection-toolbar button {
  background: none;
  border: none;
  color: var(--bg-surface);
  /* 44pt minimum touch target, same floor as every other new mobile
     control in this change (bottom nav, move-up/down, DisabledHint). */
  min-width: 44px;
  min-height: 44px;
  border-radius: 4px;
  font-size: 13px;
  cursor: pointer;
}

.selection-toolbar button.active {
  background: rgba(255, 255, 255, 0.2);
}

.disabled-hint-note {
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--text-primary);
  color: var(--bg-surface);
  font-size: 11px;
  line-height: 1.4;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  white-space: normal;
  width: max-content;
  max-width: 220px;
  z-index: 20;
  box-shadow: var(--shadow-md);
}

/* CHG-5046 Step 9: SceneSwitcherSheet — full scene list inside a BottomSheet,
   opened from MobileSceneSwitcher's compact header. Rows mirror
   SceneDrawer's desktop layout but swap draggable for explicit up/down
   reorder buttons sized to a 44pt touch target. */
.scene-switcher-sheet {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
}

.scene-switcher-sheet-actions {
  flex-shrink: 0;
  padding: 4px 4px 12px;
}

.scene-switcher-sheet-add-form {
  display: flex;
  gap: 6px;
}

.scene-switcher-sheet-add-form .input {
  flex: 1;
}

.scene-switcher-sheet-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.scene-switcher-row {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px;
  border-radius: var(--radius-sm);
}

.scene-switcher-row-selected {
  background: var(--bg-surface-low);
}

.scene-switcher-row-reorder {
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.scene-switcher-move-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  min-width: var(--touch-target-min);
  /* Each stacked up/down button is its own tap target (not half of a
     shared column) — the row grows to fit rather than shrinking each
     button below the touch-target minimum.
     CHG-6229: migrated the old "44px" literal to the shared
     --touch-target-min token (48px). */
  min-height: var(--touch-target-min);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  line-height: 1;
}

.scene-switcher-move-btn:disabled {
  color: var(--border-subtle);
  cursor: default;
}

.scene-switcher-row-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  background: none;
  border: none;
  cursor: pointer;
  text-align: left;
  padding: 6px 8px;
  /* CHG-6229: migrated the old "44px" literal to the shared --touch-target-min
     token (48px). */
  min-height: var(--touch-target-min);
  justify-content: center;
}

.scene-switcher-row-title {
  /* CHG-6229: wired to the UI tier token instead of a bespoke 13px literal,
     so it inherits the mobile legibility override automatically. */
  font-size: var(--type-ui-size);
  font-weight: 600;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}

.scene-switcher-row-words {
  /* CHG-6229: wired to the meta tier token instead of a bespoke 10px literal. */
  font-size: var(--type-meta-size);
  color: var(--text-muted);
  font-style: italic;
  opacity: 0.7;
}

.scene-switcher-delete-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 16px;
  /* CHG-6229: migrated the old "44px" literals to the shared
     --touch-target-min token (48px). */
  min-width: var(--touch-target-min);
  min-height: var(--touch-target-min);
  flex-shrink: 0;
}

.scene-switcher-row-confirm {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

/* CHG-6231: the `.mobile-book-screen`/`.mobile-book-section*` rules that
   used to live here (CHG-5046 Step 10's MobileBookScreen collapsible
   sections) were removed along with mobile-book-screen.tsx itself --
   Figures/Memories/Proposals are now reachable via the mobile Info tab
   (mobile-info-tab.tsx) instead. */

/* ============================================================================
   TYPOGRAPHY TIER CLASSES (CHG-5601)
   ============================================================================
   Single-source-of-truth tier system. Each class consumes tokens from
   src/styles/tokens.css. Change a token once to update all uses.
*/

.t-display {
  font-family: var(--type-display-family);
  font-size: var(--type-display-size);
  font-weight: var(--type-display-weight);
  letter-spacing: var(--type-display-tracking);
  text-transform: var(--type-display-case);
  color: var(--type-display-color);
}

.t-title {
  font-family: var(--type-title-family);
  font-size: var(--type-title-size);
  font-weight: var(--type-title-weight);
  letter-spacing: var(--type-title-tracking);
  text-transform: var(--type-title-case);
  color: var(--type-title-color);
}

.t-heading {
  font-family: var(--type-heading-family);
  font-size: var(--type-heading-size);
  font-weight: var(--type-heading-weight);
  letter-spacing: var(--type-heading-tracking);
  text-transform: var(--type-heading-case);
  color: var(--type-heading-color);
}

.t-label {
  font-family: var(--type-label-family);
  font-size: var(--type-label-size);
  font-weight: var(--type-label-weight);
  letter-spacing: var(--type-label-tracking);
  text-transform: var(--type-label-case);
  color: var(--type-label-color);
}

.t-action {
  font-family: var(--type-action-family);
  font-size: var(--type-action-size);
  font-weight: var(--type-action-weight);
  letter-spacing: var(--type-action-tracking);
  text-transform: var(--type-action-case);
  color: var(--type-action-color);
}

.t-action-primary {
  background: var(--accent);
  color: white;
  border-radius: var(--radius-sm);
}

.t-action-primary:hover {
  background: var(--accent-hover);
}

.t-action-secondary {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 14px; /* Compensate for 1px border */
}

.t-action-secondary:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.t-action-danger {
  background: var(--error-container);
  color: var(--error);
  border-radius: var(--radius-sm);
}

.t-badge {
  font-family: var(--type-badge-family);
  font-size: var(--type-badge-size);
  font-weight: var(--type-badge-weight);
  letter-spacing: var(--type-badge-tracking);
  text-transform: var(--type-badge-case);
  color: var(--type-badge-color);
}

.t-prose {
  font-family: var(--type-prose-family);
  font-size: var(--type-prose-size);
  font-weight: var(--type-prose-weight);
  letter-spacing: var(--type-prose-tracking);
  text-transform: var(--type-prose-case);
  color: var(--type-prose-color);
  line-height: 1.6;
}

.t-ui {
  font-family: var(--type-ui-family);
  font-size: var(--type-ui-size);
  font-weight: var(--type-ui-weight);
  letter-spacing: var(--type-ui-tracking);
  text-transform: var(--type-ui-case);
  color: var(--type-ui-color);
  line-height: 1.5;
}

.t-meta {
  font-family: var(--type-meta-family);
  font-size: var(--type-meta-size);
  font-weight: var(--type-meta-weight);
  letter-spacing: var(--type-meta-tracking);
  text-transform: var(--type-meta-case);
  color: var(--type-meta-color);
}

.t-metric {
  font-family: var(--type-metric-family);
  font-size: var(--type-metric-size);
  font-weight: var(--type-metric-weight);
  letter-spacing: var(--type-metric-tracking);
  text-transform: var(--type-metric-case);
  color: var(--type-metric-color);
}

/* ============================================================================
   END TIER CLASSES
   ============================================================================ */

/* CHG-6199: site-wide, user-selectable dark theme. Promotes CHG-5046's
   mobile-only, OS-media-query-only dark palette (same variable values,
   unchanged below) to two rules:

   (a) `:root[data-theme="dark"]` — explicit Dark, set via the `data-theme`
       attribute on <html> (src/app/layout.tsx for SSR; the theme toggle's
       optimistic DOM update client-side). Unconditional: applies on any
       viewport, regardless of OS preference. No `max-width: 768px` gate —
       desktop is no longer excluded.
   (b) the `@media (prefers-color-scheme: dark)` rule below — "System":
       applies whenever the user has NOT explicitly chosen Light or Dark
       (no `data-theme` attribute at all — see layout.tsx, which omits it
       for a 'system' preference, no session, or no stored preference) and
       the OS/browser reports dark. Also unscoped by viewport now. Because
       this lives inside a plain CSS media query (no JS), it re-evaluates
       live if the OS preference changes while the page is open — the
       System-state "live update" behavior comes for free.

   An explicit Light choice (`data-theme="light"`) matches neither rule, so
   the base (light) `:root` values above stand even when the OS is in dark
   mode — this is what makes an explicit Light choice override OS dark.

   `--accent-fixed`, `--accent-fixed-dim`, `--tertiary-fixed`,
   `--tertiary-fixed-dim`, and `--secondary-fixed` are deliberately NOT
   overridden below: per their own naming (mirroring Material Design 3's
   "fixed" color roles), these are meant to render identically regardless of
   light/dark theme — see their :root definitions above. `--radius-*`,
   `--transition*` are shape/motion tokens, not colors, and are also
   untouched. */
:root[data-theme="dark"] {
  /* Surface hierarchy */
  --bg-primary: #171310;
  --bg-secondary: #201b16;
  --bg-surface: #221e19;
  --bg-surface-low: #2a2520;
  --bg-surface-container: #262119;
  --border: #4d4238;
  --border-subtle: #322c26;

  /* Text hierarchy */
  --text-primary: #f1ece4;
  --text-secondary: #d2c6b8;
  --text-muted: #a4988a;

  /* Accent / Primary */
  --accent: #d9a870;
  --accent-hover: #e8bb87;
  --accent-container: #8d6f50;
  --accent-light: rgba(217, 168, 112, 0.14);

  /* Tertiary (AI / green) */
  --tertiary: #a8c7a9;
  --tertiary-container: #3f4c40;

  /* Chat */
  --chat-user-bg: #8d6f50;
  --chat-user-text: #fffbff;
  --chat-ai-bg: #2b3a2c;
  --chat-ai-text: #d7ead7;

  /* Secondary */
  --secondary: #c2b7a9;

  /* Status */
  --error: #ffb4ab;
  --error-container: #93000a;
  --success: #a8c7a9;

  /* Elevation — brighter/opaquer than the light theme's shadows so they
     stay visible against a dark surface rather than disappearing into it. */
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.35);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.5);
  --shadow-xl: 0 16px 48px rgba(0, 0, 0, 0.6);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]):not([data-theme="dark"]) {
    /* Identical values to the :root[data-theme="dark"] rule above — kept as
       a literal duplicate (not a shared CSS variable set) so each rule's
       scope stays self-contained and easy to read in isolation. */
    --bg-primary: #171310;
    --bg-secondary: #201b16;
    --bg-surface: #221e19;
    --bg-surface-low: #2a2520;
    --bg-surface-container: #262119;
    --border: #4d4238;
    --border-subtle: #322c26;

    --text-primary: #f1ece4;
    --text-secondary: #d2c6b8;
    --text-muted: #a4988a;

    --accent: #d9a870;
    --accent-hover: #e8bb87;
    --accent-container: #8d6f50;
    --accent-light: rgba(217, 168, 112, 0.14);

    --tertiary: #a8c7a9;
    --tertiary-container: #3f4c40;

    --chat-user-bg: #8d6f50;
    --chat-user-text: #fffbff;
    --chat-ai-bg: #2b3a2c;
    --chat-ai-text: #d7ead7;

    --secondary: #c2b7a9;

    --error: #ffb4ab;
    --error-container: #93000a;
    --success: #a8c7a9;

    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.35);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.45);
    --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.5);
    --shadow-xl: 0 16px 48px rgba(0, 0, 0, 0.6);
  }
}

/* Icon button wrapper (CHG-5705): keeps 16px icons from being squashed by
   tight button padding in flex rows. Sized by the icon token. */
.icon-button-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  width: var(--icon-size-md);
  height: var(--icon-size-md);
  flex-shrink: 0;
  line-height: 1;
}

/* CHG-6199: ThemeControl — three-way Light/Dark/System segmented control,
   rendered in ProfileMenu's dropdown and the Settings "Appearance" card.
   Layout only, no new color literals — relies entirely on existing tokens. */
.theme-control {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.theme-control-option {
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 6px 12px;
  color: var(--text-secondary);
  transition: background var(--transition), color var(--transition);
  /* 44pt minimum touch target floor, same convention as every other new
     mobile control in this codebase (bottom nav, DisabledHint, etc.) —
     height only; width stays content-driven so three labels fit one row. */
  min-height: 44px;
}

.theme-control-option:not(:last-child) {
  border-right: 1px solid var(--border);
}

.theme-control-option:hover {
  background: var(--bg-surface-low);
}

.theme-control-option[aria-checked="true"] {
  background: var(--accent-light);
  color: var(--accent);
  font-weight: 600;
}

