/* Local subsets keep the editor and exported image on the same typefaces. */
@font-face {
  font-family: "Melody Hand";
  src: url("../assets/fonts/melody-hand.woff?v=3.3.1-ui15") format("woff");
  font-style: normal;
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "Melody Rounded";
  src: url("../assets/fonts/melody-rounded-regular.woff?v=3.3.1-ui15") format("woff");
  font-style: normal;
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "Melody Rounded";
  src: url("../assets/fonts/melody-rounded-semibold.woff?v=3.3.1-ui15") format("woff");
  font-style: normal;
  font-weight: 600;
  font-display: swap;
}

/* Lily stationery: a shared palette for the entrance, editor and export. */
:root.journal-theme {
  color-scheme: light;
  --j-bg: #fbfff4;
  --j-paper: #fffffb;
  --j-ink: #414e3d;
  --j-muted: #687361;
  --j-green: #657c50;
  --j-green-dark: #4d653e;
  --j-green-soft: #edf2e2;
  --j-pink: #f3e8dd;
  --j-pink-ink: #a27b64;
  --j-line: #e1e7d5;
  --j-field: #f4f6ed;
  --j-soft-line: #edf0e5;
  --j-accent-line: #d3dec2;
  --j-detail-bg: #f8faf4;
  --j-detail-ink: #626f59;
  --j-amount-ink: #52604a;
  --j-shadow-rgb: 110 128 96;
  --j-shadow: 0 8px 28px rgb(var(--j-shadow-rgb) / 3%), 0 1px 3px rgb(var(--j-shadow-rgb) / 2%);
  --j-texture: url("../assets/lily/paper.webp?v=3.3.1-ui15");
  --j-texture-size: 100px 100px;
  --j-texture-opacity: .075;
  --j-font: "Melody Rounded", "Melody Hand", "PingFang SC", "Microsoft YaHei", sans-serif;
  --j-heading-font: "Melody Hand", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--j-bg);
  font-family: var(--j-font);
  font-synthesis: none;
  -webkit-text-size-adjust: 100%;
}
/* Keep existing saved keys; all palettes come from the lily illustrations. */
:root.journal-theme[data-theme="warm"] {
  --j-bg: #fefbef;
  --j-paper: #fffef9;
  --j-ink: #4f513d;
  --j-muted: #74745c;
  --j-green: #70763f;
  --j-green-dark: #626936;
  --j-green-soft: #f0f0d9;
  --j-pink: #f5f2df;
  --j-pink-ink: #858157;
  --j-field: #f7f6e8;
  --j-line: #e5e4cc;
  --j-soft-line: #efeedf;
  --j-accent-line: #d4d8b1;
  --j-detail-bg: #fbfaef;
  --j-detail-ink: #6d7258;
  --j-amount-ink: #595f42;
  --j-shadow-rgb: 115 121 69;
  --j-texture: url("../assets/lily/paper-rice.webp?v=3.3.1-ui15");
  --j-texture-size: 485px 485px;
  --j-texture-opacity: .055;
}
:root.journal-theme[data-theme="simple"] {
  --j-bg: #fdfdfb;
  --j-paper: #ffffff;
  --j-ink: #444d3e;
  --j-muted: #6e7567;
  --j-green: #6f785f;
  --j-green-dark: #4f5d45;
  --j-green-soft: #eef0e8;
  --j-pink: #f1f1e9;
  --j-pink-ink: #7b816d;
  --j-field: #f6f7f2;
  --j-line: #e2e5dc;
  --j-soft-line: #eff1eb;
  --j-accent-line: #d1d8c8;
  --j-detail-bg: #f8f9f6;
  --j-detail-ink: #66715e;
  --j-amount-ink: #55624e;
  --j-shadow-rgb: 103 110 91;
  --j-texture: url("../assets/lily/paper-fibers.webp?v=3.3.1-ui15");
  --j-texture-size: 410px 410px;
  --j-texture-opacity: .055;
}
.journal-theme *, .journal-theme *::before, .journal-theme *::after { box-sizing: border-box; }
.journal-theme body { margin: 0; color: var(--j-ink); background: var(--j-bg); font-size: 14px; line-height: 1.5; }
.journal-theme button, .journal-theme input, .journal-theme select { font: inherit; color: inherit; }
.journal-theme button, .journal-theme a, .journal-theme input, .journal-theme select, .journal-theme summary { -webkit-tap-highlight-color: transparent; }
.journal-theme button, .journal-theme a, .journal-theme summary { touch-action: manipulation; }
.journal-theme button { cursor: pointer; }
.journal-theme button:disabled { opacity: .6; cursor: wait; }
.journal-theme button:focus-visible, .journal-theme a:focus-visible, .journal-theme summary:focus-visible { outline: 3px solid var(--j-green); outline-offset: 3px; }
.journal-theme [hidden] { display: none !important; }
.journal-theme h1, .journal-theme h2, .journal-theme h3, .journal-theme p { margin: 0; }
.journal-theme h1, .journal-theme h2, .journal-theme h3 { font-family: var(--j-heading-font); }
.j-page img, .j-portal img, .export-dialog img { display: block; max-width: 100%; height: auto; }
.j-sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.j-numeric, [data-out] { font-variant-numeric: tabular-nums; }
.j-muted { color: var(--j-muted); }
.j-icon { width: 2.1em; aspect-ratio: 1; object-fit: contain; }
.j-primary {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  border: 1px solid var(--j-green); border-radius: 13px; padding: 11px 17px;
  background: var(--j-green); color: #fffffb !important; font-weight: 600;
  box-shadow: 0 4px 12px rgb(var(--j-shadow-rgb) / 10%); text-decoration: none;
}
.j-primary:hover { background: var(--j-green-dark); }
.j-primary:active { transform: translateY(1px); box-shadow: none; }
.j-icon-button {
  display: inline-grid; place-items: center; min-width: 44px; min-height: 44px;
  padding: 8px; border: 0; border-radius: 14px; background: transparent; color: inherit; text-decoration: none;
}
.j-icon-button:hover { background: var(--j-green-soft); }
.j-home { font-size: 28px; line-height: 1; }
.j-page { display: flex; flex-direction: column; min-height: 100svh; width: min(1080px, 100%); margin-inline: auto; padding: 0 18px calc(108px + env(safe-area-inset-bottom)); }
.j-page > .j-signature { margin-top: auto; padding-top: 30px; }
.j-signature { color: var(--j-muted); font-family: var(--j-font); font-size: 11px; font-weight: 400; letter-spacing: .035em; text-align: center; }
.j-signature::before { content: ''; display: block; width: 2.8em; height: 1px; margin: 0 auto 10px; background: var(--j-accent-line); }
.j-topbar {
  display: flex; align-items: center; gap: 7px;
  padding-block: calc(15px + env(safe-area-inset-top, 0px)) 18px;
  position: relative; z-index: 10;
}
.j-brand { min-width: 0; margin-right: auto; }
.j-car-picker {
  border: 0; background: transparent; padding: 2px 2px 2px 0; font-weight: 600 !important;
  font-size: 19px !important; min-width: 0; max-width: 100%; cursor: pointer;
}
.j-topbar .j-primary { padding-inline: 13px; white-space: nowrap; }
.j-topbar .j-primary svg { width: 1.1em; height: 1.1em; }
.theme-switcher { position: relative; }
.j-theme-symbol { font-size: 24px; color: var(--j-green); line-height: 1; }
.theme-panel {
  display: none; position: absolute; right: 0; top: calc(100% + 8px); width: max-content;
  padding: 9px; border: 1px solid var(--j-line); border-radius: 18px;
  background: var(--j-paper); box-shadow: 0 12px 40px rgb(var(--j-shadow-rgb) / 16%); z-index: 30;
  color: var(--j-ink); font-size: 14px; letter-spacing: 0;
}
.theme-panel.open { display: grid; }
.theme-title { padding: 5px 9px 8px; font-size: 12px; color: var(--j-muted); }
.theme-option { display: flex; align-items: center; gap: 9px; border: 0; border-radius: 9px; background: transparent; padding: 12px 10px; text-align: left; }
.theme-option[aria-pressed="true"] { background: var(--j-green-soft); }
.theme-option small { margin-left: auto; color: var(--j-muted); font-size: 11px; }
.theme-option::before { content: ""; width: 1em; aspect-ratio: 1; border-radius: 50%; background: #a6b76b; box-shadow: inset 0 0 0 1px #77826326; }
.theme-option[data-theme="warm"]::before { background: #efefcf; }
.theme-option[data-theme="simple"]::before { background: #fdfdfb; }
.j-reset-option { padding: 12px 10px; margin-top: 5px; border: 0; border-top: 1px solid var(--j-line); text-align: left; background: transparent; color: var(--j-muted) !important; font-size: 12px !important; }
.j-page-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin: 0 3px 14px; }
.j-page-heading h1 { font-size: 24px; letter-spacing: .06em; font-weight: 400; }
.j-page-heading p { font-size: 12px; color: var(--j-muted); margin-top: 3px; }
.j-page-heading img { width: 3.35em; aspect-ratio: 1; object-fit: contain; }
.j-paper { border: 1px solid var(--j-line); border-radius: 20px; background: var(--j-paper); box-shadow: var(--j-shadow); }
.j-section-heading { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.j-section-heading h2 { font-size: 17px; font-weight: 400; letter-spacing: .02em; }
.j-section-heading > span { color: var(--j-muted); font-size: 12px; white-space: nowrap; }
.j-section-heading b { color: var(--j-green); font-weight: 600; }
.j-record-layout { display: grid; gap: 16px; align-items: start; }
.j-setup, .j-achievements { padding: 17px; }
.j-setup { position: relative; }
.j-setup .j-section-heading, .j-achievements > .j-section-heading { margin-bottom: 11px; }
.j-setup .j-section-heading h2, .j-achievements > .j-section-heading h2 { font-size: 16px; }
.j-setup .j-section-heading > span { font-size: 11px; }
.j-setting-field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.j-setting-field > span { font-size: 12px; color: var(--j-muted); text-align: center; }
.j-setting-field .j-input { text-align: center; padding-inline: 5px; font-weight: 600; }
.j-config-grid, .j-match-fields { display: grid; grid-template-columns: repeat(var(--field-count,4),minmax(0,1fr)); gap: 10px; }
.j-weights { margin-top: 11px; }
.j-field-wrap { position: relative; min-width: 0; }
.j-field-wrap .j-input { padding-right: 22px; }
.j-field-wrap i { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); color: var(--j-muted); font-size: 12px; font-style: normal; pointer-events: none; }
.j-match-block { border-top: 1px solid var(--j-line); margin-top: 16px; padding-top: 13px; }
.j-calculated > div { display: grid; align-items: center; min-height: 44px; padding: 10px 3px; border-radius: 12px; color: var(--j-green-dark); background: var(--j-green-soft); text-align: center; font-size: 16px; line-height: 1.35; font-weight: 600; }
.j-switch { display: flex; padding: 4px; gap: 4px; border: 1px solid var(--j-line); border-radius: 15px; background: var(--j-green-soft); margin-bottom: 15px; }
.j-switch button {
  flex: 1 1 0; min-width: 0; min-height: 44px; border: 0; background: transparent;
  border-radius: 11px; padding: 9px 6px; color: var(--j-muted); font-size: 14px; font-weight: 400;
}
.j-switch button[aria-pressed="true"] { background: var(--j-paper); color: var(--j-green-dark); box-shadow: 0 2px 5px #5a6b3810; }
.j-player-switch { margin-bottom: 13px; }
.j-player-switch button { display: flex; flex-direction: column; align-items: center; gap: 1px; padding: 5px 3px; font-size: 13px; }
.j-choice-stars { color: var(--j-muted); font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums; }
.j-choice-stars small { margin-left: 3px; font-size: 10px; font-weight: 400; }
.j-player-switch [aria-pressed="true"] .j-choice-stars { color: var(--j-green-dark); }
.j-edit-mark { display: block; flex: 0 0 auto; width: 1em; aspect-ratio: 1; color: var(--j-green); }
.j-choice-name { display: inline-flex; align-items: center; gap: 3px; white-space: nowrap; }
.j-choice-name .j-edit-mark { visibility: hidden; width: .8em; }
.j-role-tabs [aria-pressed="true"] .j-edit-mark { visibility: visible; }
.j-role-edit { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 0; border: 0; border-radius: 6px; background: transparent; text-align: left; }
.j-role-edit:hover { color: var(--j-green-dark); }
.j-role-dialog { width: min(420px,calc(100% - 32px)); max-height: calc(100dvh - 32px); margin: auto; padding: 18px 22px 22px; border: 1px solid var(--j-line); border-radius: 24px; background: var(--j-paper); color: var(--j-ink); box-shadow: 0 18px 60px #38452d20; }
.j-role-dialog::backdrop { background: #343f2d50; backdrop-filter: blur(3px); }
.j-role-dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.j-role-dialog-head h2 { font-size: 20px; font-weight: 400; }
.j-role-dialog-head .j-icon-button { color: var(--j-muted); margin-right: -10px; }
.j-role-dialog-head svg { width: 1.25em; aspect-ratio: 1; }
.j-role-options { display: grid; grid-template-columns: repeat(5,minmax(0,1fr)); gap: 7px; }
.j-role-options button { display: flex; flex-direction: column; align-items: center; gap: 5px; min-width: 0; padding: 13px 3px; border: 1px solid var(--j-line); border-radius: 13px; background: var(--j-field); font-size: 15px; }
.j-role-options button small { color: var(--j-muted); font-size: 10px; }
.j-role-options button:hover { border-color: var(--j-green); }
.j-role-options button[aria-pressed="true"] { color: var(--j-green-dark); background: var(--j-green-soft); border-color: var(--j-green); }
.j-role-options button[aria-pressed="true"] small { color: var(--j-green-dark); }
.j-role-dialog > p { margin-top: 16px; color: var(--j-muted); font-size: 12px; }
.j-linked-number > .j-work-head, .j-linked-boss > .j-work-head { display: none; }
.j-player-sheet { position: relative; min-width: 0; }
.j-player-top { display: none; align-items: center; justify-content: space-between; gap: 9px; margin-bottom: 12px; }
.j-person-name { display: flex; align-items: center; gap: 9px; min-width: 0; }
.j-avatar { display: grid; place-items: center; flex: 0 0 auto; width: 2.35em; aspect-ratio: 1; background: var(--j-green-soft); border-radius: 50% 50% 50% 18%; color: var(--j-green-dark); font-size: 15px; font-weight: 600; }
.j-person-name h2, .j-person-name h3 { font-size: 16px; }
.j-stars { display: flex; align-items: baseline; gap: 4px; color: var(--j-green); }
.j-stars strong { font-size: 24px; font-weight: 700; }
.j-stars small { font-size: 11px; color: var(--j-muted); }
.j-medals { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 9px; }
.j-medal-label { display: flex; align-items: center; justify-content: center; gap: 4px; }
.j-medal-mark { display: inline-grid; place-items: center; width: 1.4em; aspect-ratio: 1; font-size: 12px; font-style: normal; color: #a3824a; background: #f5ead2; border-radius: 50%; }
.j-medal-mark[data-medal="top"] { color: #ab8871; background: #f2e0ce; }
.j-medal-mark[data-medal="silver"] { color: #879097; background: #e9edf0; }
.j-medal-mark[data-medal="bronze"] { color: #a6836c; background: #f2e5db; }
.j-input, .j-select {
  display: block; width: 100%; min-width: 0; min-height: 44px; max-width: 100%;
  padding: 10px 12px; border: 1px solid var(--j-line); border-radius: 11px;
  background: var(--j-field); color: var(--j-ink); font-size: 16px !important; line-height: 1.35;
  font-variant-numeric: tabular-nums;
}
.j-input { appearance: textfield; }
.journal-theme input[type="number"]::-webkit-inner-spin-button,
.journal-theme input[type="number"]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.j-input:focus, .j-select:focus { outline: 2px solid var(--j-green); outline-offset: 1px; background: var(--j-paper); }
.j-input[aria-invalid="true"] { border-color: #b56a59; background: #fceee7; }
.j-medals .j-input { text-align: center; padding-inline: 3px; font-weight: 600; }
.j-work-card { position: relative; padding: 22px; }
.j-work-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 22px; }
.j-work-head h2 { display: flex; align-items: center; gap: 9px; font-size: 18px; font-weight: 400; }
.j-serial { color: var(--j-muted); font-size: 15px; font-family: "Melody Rounded",sans-serif; }
.j-select { width: auto; padding: 8px 9px; background: var(--j-green-soft); color: var(--j-green-dark); }
.j-quotes { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 16px 14px; }
.j-quote { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.j-quote > span { display: flex; align-items: center; justify-content: space-between; gap: 5px; font-size: 13px; }
.j-quote > span::before { content: ''; width: 5px; aspect-ratio: 1; background: var(--j-green); border-radius: 50%; margin-right: 1px; }
.j-quote > span > b { margin-right: auto; font-weight: 500; }
.j-quote > span small { font-size: 10px; color: var(--j-muted); }
.j-money-input { position: relative; }
.j-money-input::before { content: '¥'; position: absolute; top: 50%; transform: translateY(-50%); left: 12px; color: var(--j-muted); font-size: 14px; pointer-events: none; }
.j-money-input input { padding-left: 28px; text-align: right; font-weight: 600; }
.j-work-total { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; border-top: 1px solid var(--j-line); margin-top: 22px; padding-top: 16px; }
.j-work-total > span { font-size: 13px; color: var(--j-muted); }
.j-work-total strong { color: var(--j-green-dark); font-size: 31px; line-height: 1.3; letter-spacing: -.02em; }
.j-currency { font-size: .55em; font-weight: 500; margin-right: 3px; }
.j-work-meta { display: flex; flex-wrap: wrap; gap: 4px 15px; justify-content: space-between; font-size: 11px; color: var(--j-muted); margin-top: 12px; }
.j-work-meta b { color: var(--j-green-dark); font-weight: 400; margin-left: 3px; }
.j-work-note { display: flex; align-items: center; justify-content: center; gap: 10px; color: var(--j-muted); margin-top: 26px; font-size: 11px; letter-spacing: .09em; }
.j-work-note::before, .j-work-note::after { content: ''; width: 30px; height: 1px; background: var(--j-line); }
.j-payments { display: grid; gap: 12px; }
.j-payment { display: grid; grid-template-columns: minmax(0,1.25fr) repeat(2,minmax(0,.8fr)); align-items: center; gap: 8px; padding: 12px; }
.j-payment .j-person-name { gap: 7px; }
.j-payment .j-avatar { font-size: 12px; }
.j-payment h3 { font-size: 14px; white-space: nowrap; }
.j-payment .j-person-name p { color: var(--j-muted); font-size: 10px; margin-top: 3px; white-space: nowrap; }
.j-payment .j-person-name b { color: var(--j-ink); font-weight: 500; }
.j-payment .j-kind { font-size: 9px; margin-left: 3px; }
.j-payment-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.j-person-name .j-kind { margin-left: 4px; font-size: 10px; color: var(--j-muted); font-weight: 400; }
.j-balance { display: flex; flex-direction: column; align-items: center; gap: 3px; min-width: 0; font-variant-numeric: tabular-nums; }
.j-balance small { color: var(--j-muted); font-size: 10px; font-weight: 400; }
.j-balance strong { display: grid; place-items: center; width: 100%; min-height: 44px; padding: 7px 4px; border-radius: 11px; font-size: 18px; font-weight: 600; overflow-wrap: anywhere; }
.j-balance.refund strong { background: #edf3e4; color: #526f3e; }
.j-balance.payin strong { background: #f7eee3; color: #8a5e3e; }
.j-balance.even strong { background: var(--j-field); color: var(--j-muted); }
.j-payment-bottom { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding-left: 44px; margin-top: 4px; color: var(--j-muted); font-size: 12px; }
.j-payment-bottom b { color: var(--j-ink); font-weight: 500; }
.j-deposit { display: flex; flex-direction: column; align-items: center; gap: 3px; color: var(--j-muted); font-size: 10px; min-width: 0; }
.j-deposit input { width: 100%; min-height: 44px; padding: 7px; text-align: center; }
.j-income { padding: 16px; }
.j-income .j-payment-top > strong { color: var(--j-green-dark); font-size: 28px; font-variant-numeric: tabular-nums; }
.j-breakdown { border-top: 1px solid var(--j-line); margin-top: 10px; padding-top: 3px; }
.j-breakdown summary { cursor: pointer; font-size: 11px; color: var(--j-muted); padding: 9px 0 3px; }
.j-breakdown-list { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 8px 16px; padding-top: 10px; font-size: 12px; }
.j-breakdown-list span { display: flex; justify-content: space-between; gap: 8px; color: var(--j-muted); }
.j-breakdown-list b { color: var(--j-ink); font-weight: 500; }
.j-reset-row { display: flex; align-items: center; justify-content: space-between; gap: 15px; margin: 18px 3px 0; color: var(--j-muted); font-size: 11px; }
.j-reset-row button { padding: 12px 7px; border: 0; background: transparent; color: #9a8b76; font-size: 12px; text-decoration: underline; text-underline-offset: 4px; }
.j-error { padding: 12px 15px; margin-top: 16px !important; background: #f8e8df; color: #a45d46; border-radius: 12px; }
.j-save-error { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 12px; margin: 0 0 16px !important; }
.j-save-error button { min-height: 44px; padding: 8px 0; border: 0; background: transparent; color: inherit; text-decoration: underline; text-underline-offset: 4px; }
.j-bottom-nav {
  display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 5px;
  position: fixed; left: 50%; bottom: calc(12px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 20;
  width: min(490px,calc(100% - 28px)); padding: 5px;
  background: var(--j-paper); border: 1px solid var(--j-line);
  border-radius: 22px; box-shadow: 0 8px 35px rgb(var(--j-shadow-rgb) / 10%);
}
.j-bottom-nav button { display: flex; align-items: center; justify-content: center; flex-direction: column; gap: 3px; min-height: 44px; border: 0; border-radius: 16px; background: transparent; padding: 5px 8px; color: var(--j-muted); font-size: 12px; line-height: 1.4; }
.j-bottom-nav img { width: 2.8em; aspect-ratio: 1; object-fit: contain; }
.j-bottom-nav button[aria-selected="true"] { color: var(--j-green-dark); background: var(--j-green-soft); font-weight: 600; }
.j-saved { font-size: 10px; letter-spacing: .13em; color: #a7a38f; }
.j-desktop-label { display: none; }

/* The generated image is a separate document; this dialog only displays it. */
.export-dialog { width: min(610px,calc(100% - 20px)); max-height: calc(100dvh - 20px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px)); margin: max(10px, env(safe-area-inset-top, 0px)) auto max(10px, env(safe-area-inset-bottom, 0px)); padding: 0; border: 1px solid var(--j-line); border-radius: 23px; background: var(--j-bg); color: var(--j-ink); }
.export-dialog::backdrop { background: #373b2e70; backdrop-filter: blur(4px); }
.export-dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; position: sticky; top: 0; z-index: 1; background: var(--j-paper); border-bottom: 1px solid var(--j-line); padding: 10px 16px; }
.export-dialog-head strong { font-size: 14px; font-weight: 600; }
.export-dialog button, .export-dialog a { padding: 11px 16px; border: 1px solid var(--j-line); border-radius: 13px; background: var(--j-paper); color: var(--j-green-dark); font: inherit; text-decoration: none; cursor: pointer; }
.export-dialog-head button { border: 0; padding: 10px; background: transparent; }
.export-image-wrap { padding: 10px; }
.export-dialog img { display: block; width: 100%; height: auto; }
.export-dialog-actions { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 10px; padding: 6px 12px 16px; }
.export-dialog-actions p { flex-basis: 100%; text-align: center; font-size: 12px; }
.export-dialog-actions #exportSave { background: var(--j-green); border-color: var(--j-green); color: #fffdf5; }

/* Shared paper backdrop; keep texture behind the cover and editor content. */
.journal-theme.j-portal-page,
.journal-theme[data-car],
.journal-theme.j-portal-page body,
.journal-theme[data-car] body { background: var(--j-bg); }
.journal-theme .settle-app {
  position: relative;
  isolation: isolate;
  min-height: 100svh;
}
.settle-app > .j-page { position: relative; z-index: 1; }
/* A small botanical cover; the three links stay in one phone screen. */
.j-portal {
  display: flex;
  flex-direction: column;
  position: relative;
  isolation: isolate;
  min-height: 100svh;
  overflow: hidden;
  padding: calc(22px + env(safe-area-inset-top, 0px)) 24px calc(24px + env(safe-area-inset-bottom, 0px));
  background: var(--j-bg);
}
/* Licensed paper textures, adapted under CC BY-SA 3.0.
   Attribution and changes: ../assets/lily/paper-LICENSE.txt. */
.j-portal::before,
.journal-theme .settle-app::before,
.bill::before {
  content: '';
  pointer-events: none;
  position: absolute;
  inset: 0;
  z-index: 0;
  background-image: var(--j-texture);
  background-size: var(--j-texture-size);
  background-repeat: repeat;
  opacity: var(--j-texture-opacity); /* Default A stays at 50%: .15 * .5. */
}
.j-portal-inner { display: flex; flex: 1; flex-direction: column; position: relative; z-index: 1; width: 100%; max-width: 980px; margin-inline: auto; }
.j-portal-layout { margin-block: auto; }
.j-portal-brand { display: flex; align-items: center; justify-content: flex-end; gap: 8px; position: relative; z-index: 10; margin-bottom: 15px; }
.j-portal-brand .j-help-button { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; padding: 8px 12px; border: 1px solid var(--j-line); border-radius: 999px; background: var(--j-paper); color: var(--j-green-dark); font-size: 12px; letter-spacing: 0; white-space: nowrap; }
.j-help-button svg { width: 1.2em; height: 1.2em; }
.j-portal-brand .j-help-button:hover { background: var(--j-green-soft); }
.j-portal-hero { position: relative; padding: 0 0 19px; text-align: center; }
.j-portal-illustration { position: relative; width: min(66%,230px); margin: 0 auto 1px; }
.j-portal-art { position: relative; width: 100%; margin: 0; }
.j-portal-hero h1 { position: relative; color: var(--j-ink); font-size: 32px; line-height: 1.5; font-weight: 400; letter-spacing: .1em; }
.j-portal-hero h1 span { color: var(--j-green-dark); }
.j-portal-hero p { position: relative; color: var(--j-muted); font-size: 12px; letter-spacing: .18em; margin-top: 3px; }
.j-car-tickets { display: grid; gap: 12px; width: 100%; max-width: 460px; margin: 3px auto 0; }
.j-car-ticket { display: flex; align-items: center; gap: 17px; position: relative; padding: 12px 19px; background: var(--j-paper); border: 1px solid var(--j-line); border-radius: 18px; box-shadow: 0 5px 16px rgb(var(--j-shadow-rgb) / 12%); text-decoration: none; color: var(--j-ink); transition: transform .18s ease,border-color .18s ease,box-shadow .18s ease; }
.j-car-ticket:hover { transform: translateY(-2px); border-color: var(--j-accent-line); box-shadow: 0 8px 18px rgb(var(--j-shadow-rgb) / 16%); }
.j-car-name { min-width: 0; margin-right: auto; }
.j-car-name strong { display: block; font-size: 21px; font-weight: 600; letter-spacing: .03em; }
.j-car-ticket > .j-car-art { flex: 0 0 auto; width: 4.2em; aspect-ratio: 1; object-fit: contain; }
.j-car-arrow { display: grid; place-items: center; flex: 0 0 auto; width: 1.8em; aspect-ratio: 1; border: 1px solid var(--j-accent-line); border-radius: 50%; color: var(--j-green); font-size: 17px; line-height: 1; }
.j-car-arrow svg { display: block; width: 1.1em; height: 1.1em; }
.j-portal-footer { margin-top: auto; padding-top: 25px; }

.journal-theme.j-help-open { overflow: hidden; }
.j-help-dialog { width: min(560px,calc(100% - 32px)); max-height: calc(100dvh - 32px); margin: auto; padding: 0; overflow: hidden; border: 1px solid var(--j-line); border-radius: 24px; background: var(--j-paper); color: var(--j-ink); box-shadow: 0 18px 60px #38452d20; }
.j-help-dialog[open] { display: flex; flex-direction: column; }
.j-help-dialog::backdrop { background: #343f2d50; backdrop-filter: blur(3px); }
.j-help-head { display: flex; flex: 0 0 auto; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px 12px 22px; border-bottom: 1px solid var(--j-line); }
.j-help-head h2 { font-size: 20px; font-weight: 400; }
.j-help-head svg { width: 1.25em; height: 1.25em; }
.j-help-body { min-height: 0; padding: 20px 22px max(24px,env(safe-area-inset-bottom)); overflow-y: auto; overscroll-behavior: contain; font-size: 13px; line-height: 1.8; }
.j-help-body .j-help-intro { margin-bottom: 20px; color: var(--j-muted); }
.j-help-steps { display: grid; gap: 18px; margin: 0; padding: 0; list-style: none; }
.j-help-steps li { display: grid; grid-template-columns: auto minmax(0,1fr); align-items: start; gap: 12px; }
.j-help-number { padding: 3px 7px; border-radius: 8px; background: var(--j-green-soft); color: var(--j-green-dark); font-size: 12px; font-variant-numeric: tabular-nums; }
.j-help-body h3 { margin-bottom: 3px; color: var(--j-green-dark); font-size: 16px; font-weight: 400; }
.j-help-export { margin-top: 22px; padding: 15px 16px; border-radius: 14px; background: var(--j-field); }
.j-help-questions { margin-top: 22px; }
.j-help-questions details { border-top: 1px solid var(--j-line); }
.j-help-questions summary { padding: 12px 0; cursor: pointer; color: var(--j-green-dark); }
.j-help-questions summary::marker { color: var(--j-green); }
.j-help-questions p { padding-bottom: 14px; }

@media (max-width: 599px) {
  .j-role-dialog { width: 100%; max-width: none; margin: auto 0 0; padding: 18px 20px max(24px,env(safe-area-inset-bottom)); border-bottom: 0; border-radius: 24px 24px 0 0; }
  .j-help-dialog { width: 100%; max-width: none; max-height: calc(100dvh - 24px); margin: auto 0 0; border-bottom: 0; border-radius: 24px 24px 0 0; }
}
@media (max-width: 359px) {
  .j-page { padding-inline: 12px; }
  .j-topbar { gap: 3px; }
  .j-car-picker { font-size: 17px !important; }
  .j-topbar .j-primary { padding-inline: 10px; font-size: 13px; }
  .j-topbar .j-primary svg { display: none; }
  .j-medals { gap: 6px; }
  .j-setup, .j-achievements, .j-work-card { padding: 14px; }
  .j-payment { padding-inline: 10px; }
  .j-payment-bottom { padding-left: 0; }
  .j-config-grid, .j-match-fields { gap: 7px; }
  .j-field-wrap i { right: 8px; }
  .j-medal-label { gap: 2px; }
  .j-portal { padding-inline: 20px; }
  .j-portal-hero h1 { font-size: 28px; }
  .j-car-ticket { gap: 12px; padding: 10px 14px; }
  .j-car-ticket > .j-car-art { width: 3.8em; }
}
@media (min-width: 600px) {
  .j-page { padding-inline: 30px; }
  .j-setup, .j-achievements { padding: 22px; }
  .j-payments { grid-template-columns: repeat(auto-fit,minmax(min(100%,20rem),1fr)); gap: 14px; }
  .j-payment-bottom { padding-left: 0; }
  .j-work-card { padding: 25px; }
  .j-portal { padding: calc(30px + env(safe-area-inset-top, 0px)) 42px calc(30px + env(safe-area-inset-bottom, 0px)); }
  .j-portal-inner { width: 100%; }
  .j-portal-brand { margin-bottom: 25px; }
  .j-portal-illustration { width: min(46%,290px); }
  .j-portal-hero h1 { font-size: 38px; }
  .j-car-tickets { grid-template-columns: repeat(3,minmax(0,1fr)); gap: 16px; max-width: 760px; }
  .j-car-ticket { flex-direction: column; text-align: center; padding: 21px 12px 17px; gap: 10px; }
  .j-car-name { margin-right: 0; }
  .j-car-ticket > .j-car-art { width: 5em; }
  .j-car-arrow { position: absolute; right: 10px; top: 10px; font-size: 13px; }
  .j-portal-hero { padding-bottom: 28px; }
}
@media (min-width: 900px) {
  .j-page { padding-top: 18px; padding-bottom: 40px; }
  .j-topbar { padding-bottom: 24px; border-bottom: 1px solid var(--j-line); margin-bottom: 28px; }
  .j-bottom-nav { position: static; z-index: auto; transform: none; margin: 0 0 25px auto; width: min(500px,100%); padding: 6px; border: 1px solid var(--j-line); border-radius: 18px; box-shadow: none; }
  .j-bottom-nav button { flex-direction: row; gap: 9px; padding: 8px 12px; font-size: 13px; }
  .j-bottom-nav img { width: 2em; }
  .j-page-heading { margin-bottom: 25px; }
  .j-page-heading h1 { font-size: 27px; }
  .j-page-heading img { width: 3.7em; }
  .j-record-layout { grid-template-columns: minmax(0,.9fr) minmax(0,1.3fr); gap: 22px; }
  .j-achievements .j-switch, .j-number-section > .j-switch, .j-split-section > .j-switch { display: none; }
  .j-deck { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 20px; align-items: start; }
  .j-linked-number > .j-work-head, .j-linked-boss > .j-work-head { display: flex; }
  .j-player-deck { grid-template-columns: repeat(auto-fit,minmax(min(100%,210px),1fr)); gap: 12px; }
  .j-player-sheet { padding: 14px 11px; border: 1px solid var(--j-line); border-radius: 17px; }
  .j-player-sheet:last-child:nth-child(odd) { grid-column: 1/-1; }
  .j-player-top { display: flex; }
  .j-player-deck .j-medals { gap: 5px; }
  .j-player-deck .j-avatar { font-size: 12px; }
  .j-player-deck .j-stars { gap: 3px; }
  .j-player-deck .j-stars strong { font-size: 23px; }
  .j-player-deck .j-stars small { display: none; }
  .j-number-section .j-work-card:only-child, .j-split-section .j-work-card:only-child { max-width: 620px; width: 100%; margin-inline: auto; grid-column: 1/-1; }
  .j-payments { grid-template-columns: repeat(auto-fit,minmax(min(100%,20rem),1fr)); }
  .j-desktop-label { display: inline; }
  .j-portal-layout { display: grid; grid-template-columns: 1.15fr 1fr; align-items: center; gap: 72px; }
  .j-portal-hero { padding: 10px 0 24px; }
  .j-portal-illustration { width: 92%; max-width: 390px; margin-bottom: 7px; }
  .j-portal-hero h1 { font-size: 43px; }
  .j-car-tickets { grid-template-columns: 1fr; gap: 18px; margin-top: 0; }
  .j-car-ticket { flex-direction: row; text-align: left; padding: 19px 23px; gap: 22px; }
  .j-car-ticket > .j-car-art { width: 5em; }
  .j-car-name { margin-right: auto; }
  .j-car-name strong { font-size: 24px; }
  .j-car-arrow { position: static; font-size: 18px; }
  .j-portal-footer { padding-top: 44px; }
}
@media (prefers-reduced-motion: reduce) {
  .journal-theme * { scroll-behavior: auto !important; transition: none !important; }
}
@media (min-width: 1100px) {
  html[data-car="32"] .j-number-section .j-deck { grid-template-columns: repeat(3,minmax(0,1fr)); }
}
