/* Shared product UI. Load after screen-specific styles in both entrypoints. */
:root {
  --ui-font: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans KR", "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  --ui-control-border: #b9c5b8;
  --ui-control-bg: #fffdf7;
  --ui-control-text: #254b3b;
  --ui-focus: #315b4a;
  --gold-text: #73531f;
}
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body { font-family: var(--ui-font); font-size: 14px; line-height: 1.6; }
:is(#app, #react-root) :where(h1, h2, h3, h4, p, small, span, b, strong, em, label, li, summary, button, input, select, textarea) {
  font-family: var(--ui-font);
}
:is(#app, #react-root) h1 { font-size: 28px; line-height: 1.3; font-weight: 700; letter-spacing: -.025em; }
:is(#app, #react-root) h2 { font-size: 20px; line-height: 1.4; letter-spacing: -.015em; }
:is(#app, #react-root) h3 { font-size: 17px; line-height: 1.45; }
:is(#app, #react-root) h4 { font-size: 15px; line-height: 1.5; }
:is(#app, #react-root) p { font-size: 14px; line-height: 1.65; }
:is(#app, #react-root) small { font-size: 12px; line-height: 1.5; }
:is(#app, #react-root) :is(button, input, select, textarea) { font-family: var(--ui-font); font-size: 14px; line-height: 1.45; }
:is(#app, #react-root) :is(h1, h2, h3, h4, p, label, summary) { overflow-wrap: anywhere; }
:is(#app, #react-root) :is(input, select, textarea) { min-width: 0; max-width: 100%; }
:is(#app, #react-root) :is(button, summary) { touch-action: manipulation; }
:is(#app, #react-root) button:disabled { cursor: not-allowed; }
/* Preserve the existing brand mark rather than restyling it as body copy. */
#app .seal :is(span, b), #app .rail nav i { font-family: 'Noto Serif KR', serif; }
#app .page-head, #app .tier-page-head, #app .formation-command-head { margin-bottom: 24px; padding-bottom: 20px; }
#app .page-head { display: flex; flex-wrap: wrap; align-items: start; gap: 24px; }
#app .page-head > div:first-child { flex: 1 1 240px; }
#app .page-head > div { min-width: 0; }
#app .page-head > div > span, #app .tier-page-head span { font-size: 14px; line-height: 1.6; }
#app .page-head > div > p, #app .tier-page-head > div > p, #app .bl-head p { font-size: 12px; letter-spacing: .08em; }
#app .head-tools { flex: 2 1 380px; display: grid; grid-template-columns: minmax(0, 1fr); min-width: 0; width: 100%; gap: 12px; margin-top: 0; }
#app .search-box { display: flex; align-items: center; gap: 8px; width: 100%; height: auto; min-height: 44px; padding: 8px 12px; border: 1px solid var(--ui-control-border); border-radius: 6px; background: var(--ui-control-bg); }
#app .search-box input { flex: 1; width: 100%; min-width: 0; min-height: 28px; padding: 0; }
#app .search-box svg, #app .search-box kbd { flex: none; }
#app .search-box kbd { font-size: 12px; }
#app .head-tools :is(.ownership-filter, .bulk-roster-actions) { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: flex-start; }
#app .bulk-roster-actions > p { flex-basis: 100%; margin: 0; font-size: 12px; letter-spacing: normal; font-weight: 400; }
#app .filter-line { gap: 8px; flex-wrap: wrap; align-items: center; overflow: visible; margin-inline: 0; padding-inline: 0; }
#app .filter-line > div { display: flex; flex-wrap: wrap; height: auto; min-height: 44px; min-width: 0; max-width: 100%; }
#app .filter-line button { min-height: 44px; padding: 8px 10px; }
#app .filter-line select { min-height: 44px; height: auto; min-width: 0; max-width: 100%; padding: 8px 10px; }
/* Action buttons added by the daily workflow use the same shape and states. */
:is(#app, #react-root) :is(.daily-start, .squad-collections, .saved-squad-board, .portfolio-guidance, .portfolio-locks, .battle-edit-return, .ownership-filter, .bulk-roster-actions, .bl-settings, .yanwu-reference-notes, .db-restore-dialog, .editor-recovery) button {
  min-height: 44px; max-width: 100%; padding: 9px 12px; margin: 0;
  border: 1px solid var(--ui-control-border); border-radius: 6px;
  background: var(--ui-control-bg); color: var(--ui-control-text); white-space: normal;
}
:is(#app, #react-root) :is(.ownership-filter, .slot-lock-actions, .portfolio-locks) button[aria-pressed=true] {
  background: #254f3e; color: #fff; border-color: #254f3e;
}
@media (hover:hover) {
  :is(#app, #react-root) :is(.daily-start, .squad-collections, .saved-squad-board, .portfolio-guidance, .bl-settings, .ownership-filter, .bulk-roster-actions) button:not(:disabled):not([aria-pressed=true]):not([data-daily-action]):hover {
    background: #edf2e9; border-color: #6b8b76;
  }
}
:is(#app, #react-root) :is(button, input, select, textarea, summary, a):focus-visible { outline: 3px solid var(--ui-focus); outline-offset: 3px; }
#app :is(.daily-start, .saved-squad-board, .squad-collections, .portfolio-guidance, .battle-edit-return) {
  border-radius: 8px; padding: 20px; line-height: 1.6;
}
#app :is(.collection-actions, .slot-lock-actions, .portfolio-mode, .bl-settings) { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
#app .collection-actions { margin: 12px 0; }
#app .squad-collections label { font-size: 13px; font-weight: 600; }
#app .squad-collections input { display: block; width: min(100%, 460px); min-height: 44px; margin-top: 6px; padding: 9px 12px; border: 1px solid var(--ui-control-border); border-radius: 6px; background: var(--ui-control-bg); color: var(--ink); }
#app .squad-collections summary { display: flex; align-items: center; min-height: 44px; gap: 8px; font-size: 14px; font-weight: 600; cursor: pointer; }
#app .squad-collections summary::before { content: '▸'; }
#app .squad-collections details[open] > summary::before { content: '▾'; }
#app .collection-teams { gap: 16px; }
#app .collection-teams article { padding: 16px; border-radius: 6px; }
#app .collection-teams li { margin-block: 10px; }
#app .collection-teams li span { margin-top: 4px; font-size: 13px; color: var(--muted); }
#app .collection-record form { margin-top: 12px; }
#app .collection-record form label { flex: 1 1 200px; }
#app .collection-record > button { margin-left: 8px; }
#app .saved-formations article b { font-size: 14px; white-space: normal; }
#app .saved-formations article small, #app .saved-formations > header span { font-size: 12px; }
#app .saved-squad-board button { margin: 4px 6px 4px 0; }
#app .portfolio-guidance-plan { padding: 16px; }
#app .portfolio-guidance-plan li { min-width: 0; }
#app .portfolio-guidance-plan button { margin-block: 6px; }
#app .bl-head { align-items: flex-start; flex-wrap: wrap; }
#app .bl-controls { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px 16px; align-items: start; }
#app .bl-controls label { min-width: 0; display: grid; gap: 6px; font-size: 13px; }
#app .bl-controls select { width: 100%; min-height: 44px; }
#app .bl-controls > span { grid-column: 1 / -1; font-size: 12px; text-align: left; line-height: 1.6; }
#app .bl-controls > span small { display: inline; }
/* Navigation must scroll on short screens instead of covering the last items. */
#app .rail { overflow-y: auto; overscroll-behavior: contain; }
#app .rail > .seal { flex: none; height: 88px; }
#app .rail nav { flex: none; padding: 12px 8px; gap: 4px; }
#app .rail nav button { min-height: 60px; }
#app .rail-foot { flex: none; }
#app .drawer-shade { z-index: 2400; }
:is(#app, #react-root) .db-restore-dialog { width: min(640px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); overflow-y: auto; overscroll-behavior: contain; padding: 20px; }
:is(#app, #react-root) .db-restore-dialog h2 { margin-top: 0; }
:is(#app, #react-root) .db-restore-dialog button { margin: 8px 8px 0 0; }
:is(#app, #react-root) .db-workspace-head, :is(#app, #react-root) .db-workspace-tabs, :is(#app, #react-root) .db-panel { font-family: var(--ui-font); }
:is(#app, #react-root) .db-workspace-tabs button { font-size: 14px; }
:is(#app, #react-root) .db-backup-tools :is(button, label) { font-family: var(--ui-font); font-size: 13px; }
:is(#app, #react-root) .db-panel-title h1 { font-size: 28px; }
@media (max-width: 1080px) {
  #app .page-head { gap: 18px; }
  #app .page-head > div:first-child, #app .head-tools { flex-basis: 100%; }
  #app .bl-controls { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  #app .bl-controls > label:last-of-type { grid-column: 1 / -1; }
}
@media (max-width: 767px) {
  :is(#app, #react-root) h1, :is(#app, #react-root) .db-panel-title h1 { font-size: 24px; }
  :is(#app, #react-root) :is(input, select, textarea) { font-size: 16px; }
  #app .workspace { padding: 24px 16px 56px; }
  #app .page-head { gap: 16px; }
  #app :is(.daily-start, .saved-squad-board, .squad-collections, .portfolio-guidance, .battle-edit-return) { padding: 16px; }
  #app .head-tools .ownership-filter button { flex: 1 1 auto; }
  #app .bulk-roster-actions button { flex: 1 1 140px; }
  #app .bl-settings > button { flex: 1 1 140px; }
  #app .collection-record > button { display: block; margin: 8px 0; }
  :is(#app, #react-root) .db-restore-dialog { padding: 16px; }
}
#app :is(.formation-command-head, .head-tools, .tier-page-head, .bl-head) > button,
#app .formation-command-head > div > button {
  min-height: 44px; padding: 9px 12px; border: 1px solid var(--ui-control-border);
  border-radius: 6px; background: var(--ui-control-bg); color: var(--ui-control-text); white-space: normal;
}
#app .formation-command-head > div:last-child { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; min-width: 0; }
#app .builder-steps { display: flex; flex-wrap: wrap; gap: 8px 16px; overflow: visible; }
#app .builder-steps > span { display: inline-flex; align-items: center; gap: 6px; min-height: 32px; white-space: normal; }
#app .formation-command-head { flex-wrap: wrap; gap: 20px; }

/* Flexible rows also reflow when the user enlarges the page. */
#app .fate-list, #app .fate-row { overflow: visible; }
#app .fate-row { grid-template-columns: minmax(0, 1fr) minmax(0, 160px) 64px 20px; gap: 12px; }
#app .fate-row > div:first-child { min-width: 0; }
#app .fate-row p { white-space: normal; overflow: visible; max-width: none; overflow-wrap: anywhere; }
#app .fate-heroes { display: flex; flex-wrap: wrap; gap: 4px; min-width: 0; overflow: visible; }
#app .fate-heroes > :is(span, b) { flex: none; margin: 0; }
#app .roster-summary { grid-template-columns: repeat(auto-fit, minmax(min(100%, 140px), 1fr)); gap: 16px; }
#app .roster-summary > div { min-width: 0; }
#app .roster-summary > p { grid-column: 1 / -1; }
#app .roster-summary .roster-summary-actions { display: flex; flex-wrap: wrap; grid-column: 1 / -1; gap: 8px; border: 0; }
#app .roster-summary-actions button { min-height: 44px; height: auto; border-radius: 6px; }
#app .tier-catalog > article { grid-template-columns: 38px minmax(0, 1fr) 72px; grid-template-rows: auto auto; gap: 12px; padding: 12px 0; }
#app .catalog-open { grid-column: 3; grid-row: 1; }
#app .catalog-apply { grid-column: 3; grid-row: 2; }
#app .catalog-heroes { grid-column: 2; grid-row: 2; display: flex; flex-wrap: wrap; min-width: 0; width: auto; max-width: 100%; gap: 8px; padding: 0; overflow: visible; }
#app .catalog-heroes button { flex: 0 1 auto; min-width: 0; width: auto; max-width: 100%; padding: 4px 0; }
#app .catalog-heroes button span { display: block; }
#app .formation-command-head [data-logout], #app .tier-page-head > [data-logout] { display: none; }
#app .formation-command-head span { font-size: 14px; line-height: 1.6; }
#app .builder-steps > span { font-size: 12px; }
@media (max-width: 767px) {
  #app .fate-row { grid-template-columns: minmax(0, 1fr) 56px 18px; }
  #app .fate-heroes { display: none; }
}

/* An informational footer must not intercept editing controls at high zoom. */
#app .statusbar { position: static; height: auto; min-height: 34px; flex-wrap: wrap; gap: 6px 16px; padding: 8px 24px; }
#app .statusbar span { min-width: 0; overflow-wrap: anywhere; }
#app .app-shell { padding-bottom: 0; }
@media (min-width: 1100px) {
  #react-root .db-toolbar { display: grid; grid-template-columns: minmax(0, 1fr) auto; border-bottom: 1px solid #d9dfd5; }
  #react-root .db-workspace-head { grid-column: 1 / -1; }
  #react-root .db-workspace-tabs { grid-column: 1; grid-row: 2; border-bottom: 0; padding-block: 8px; }
  #react-root .db-backup-tools { grid-column: 2; grid-row: 2; border-bottom: 0; padding-block: 8px; align-self: stretch; }
  #react-root .db-backup-message { grid-column: 1 / -1; }
}

/* Continue, registration and apply actions share the existing jade palette. */
#app button:is([data-daily-action], [data-roster-start], [data-roster-back]),
#app .tier-resource-status button,
#app .formation-completion-list > article > footer > button {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; height: auto; max-width: 100%; padding: 10px 16px; margin: 0;
  border: 1px solid #315b4a; border-radius: 4px; background: transparent; color: #234b3b;
  font-size: 14px; font-weight: 600; line-height: 1.5; white-space: normal;
}
#app button:is([data-roster-start], [data-daily-action=edit], [data-daily-action=heroes], [data-daily-action=skills]),
#app .tier-resource-status > button,
#app .formation-completion-list > article > footer > button { background: #315b4a; color: #fffdf7; }
/* Keep the source warning and its action on separate rows in both hosts. */
#app .tier-resource-status {
  display: grid; grid-template-columns: minmax(0, 1fr); justify-items: start;
  align-items: start; gap: 10px; min-width: 0; overflow-wrap: anywhere;
}
#app .tier-resource-status > * { min-width: 0; max-width: 100%; }
#app .tier-resource-status p { margin: 0; }
#app .tier-resource-status small { display: block; line-height: 1.5; }
#app .tier-resource-status button { overflow-wrap: anywhere; }
#app .tier-resource-status button:focus-visible { outline: 2px solid #234b3b; outline-offset: 3px; }
@media (max-width: 480px) {
  #app .tier-resource-status > button { width: 100%; }
}
#app .daily-start { background: #eeeadf; border-color: #d4cdbd; }
#app .daily-start > div { display: flex; flex-wrap: wrap; gap: 10px; }
#app .formation-completion-list > article { display: flex; flex-direction: column; }
#app .formation-completion-list > article > footer > p {
  flex: none; display: block; width: 100%; min-width: 0; max-width: none;
  margin: 0; color: #514e44; line-height: 1.65; white-space: normal; overflow-wrap: anywhere;
}
#app .formation-completion-list > article > footer > button { width: 100%; }
#app .formation-completion-actions { flex-wrap: wrap; align-items: center; gap: 12px; }
#app .formation-completion-actions > div { flex-wrap: wrap; gap: 8px; }
#app .completion-meter { height: 26px; }
#app .completion-meter strong {
  inset: 2px 4px 2px auto; min-width: 44px; padding: 0 6px; border-radius: 2px;
  background: #fffaf0; color: #234b3b; font-size: 12px; text-shadow: none;
}
#app .completion-assets button.missing { opacity: 1; filter: none; }
#app .completion-assets button.missing img { opacity: .65; filter: grayscale(1); }
#app .completion-assets button > small { color: #514e44; }
#app :is(.command-deck, .audit-lead, .data-ribbon, .formation-canvas, .mini-formation) { --gold-text: #d9bd7d; }
#app .builder-portrait label { color: #f1f0e6; }
#app .builder-portrait select { color: #182b21; }
#app .builder-hero > header span { color: #694b20; }
#app .loadout-skill small { color: #655d51; }
#app .filter-line button b { color: #655d51; }
#app .rail-foot :is(small, span) { color: #adb7ae; }
#react-root .db-brand small { color: #625d53; }
#app .game-value { color: #126846; }
@media (hover:hover) {
  #app button:is([data-roster-start], [data-daily-action=edit], [data-daily-action=heroes], [data-daily-action=skills]):not(:disabled):hover,
  #app .tier-resource-status > button:not(:disabled):hover,
  #app .formation-completion-list > article > footer > button:not(:disabled):hover { background: #234b3b; color: #fffdf7; border-color: #234b3b; }
  #app .tier-resource-status .reference-repair button:not(:disabled):hover { background: #e2e7dd; color: #234b3b; border-color: #234b3b; }
  #app button:is([data-daily-action=yanwu], [data-roster-back]):not(:disabled):hover { background: #e2e7dd; color: #234b3b; border-color: #234b3b; }
}

#app .formation-completion-list { grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr)); }

/* Readable foregrounds are chosen for the surface, not by reducing the
   opacity of an entire control (which also fades its name and status). */
#app .login-panel{--gold-text:#d9bd7d}
#app .login-panel>small{color:#adb7ae}
#app .game-term,#app .term-glossary article>span{color:#73531f}
#app .catalog-loadout button:not(.owned){opacity:1;color:#625d53}
#app .tier-skills button:not(.owned){opacity:1;color:#d5dbd4}
#app .tier-skills button:not(.owned) small{color:#b3beb5}
#app .tier-dossier{color:var(--ink)}
#app .tier-hero-name{font:inherit;color:inherit;border:0;background:none;padding:0;min-height:36px;text-align:left}
#app .yanwu-plan-entity.missing{color:#625d53}
#app .hero-codex-flags .season.s2{background:#73531f;color:#fffdf7}
#app :is(.yanwu-treasure-choices,.yanwu-manual-groups) button:disabled,
#app .yanwu-command>footer button:disabled,
#app .yanwu-support article [data-yanwu-support-remove]:disabled,
#app .battle-lab button:disabled{opacity:1;color:#625d53;border-color:#b9b7ae;background:#e8e5dc;cursor:not-allowed}
#app .battle-lab button.bl-primary:disabled{color:#625d53;background:#e8e5dc;border-color:#b9b7ae}

:is(#app,#react-root) :is(input,textarea)::placeholder{color:#625d53;opacity:1}
#app .login-panel input::placeholder{color:#adb7ae}

#app .candidate-skill-list>button.conflict{opacity:1}
#app .candidate-skill-list>button.conflict :is(.candidate-reason,.skill-fit-score b){color:#853f31}

/* Work continuity uses the existing palette and typography. */
.work-return,.editor-origin{padding:16px;margin:12px 0;border:1px solid var(--line,#c9d1c9);border-radius:8px;background:var(--paper,#fff);color:var(--ink,#17251d);overflow-wrap:anywhere}
.work-return{display:flex;align-items:center;gap:12px;flex-wrap:wrap}
.work-return button,.editor-origin button,[data-portfolio-collect]{min-height:44px;white-space:normal;padding:10px 14px;background:#24583f;color:#fff;border:1px solid #24583f;border-radius:6px}
.editor-origin button{margin:4px}.editor-origin ul{padding-left:22px}.editor-origin details{margin:10px 0}.picker-method summary{cursor:pointer;color:inherit}
[data-daily-action="edit"]{min-width:min(100%,180px);white-space:normal;word-break:keep-all}
@media(max-width:480px){.work-return button,.editor-origin button,[data-portfolio-collect]{width:100%}.editor-origin{padding:12px}}
[data-yanwu-conflict-jump],[data-yanwu-conflict-group],.yanwu-correction-return,[data-search-reset]{min-height:44px;padding:10px 14px;margin:4px;border:1px solid #24583f;border-radius:6px;background:#24583f;color:#fff;white-space:normal;overflow-wrap:anywhere}
[data-yanwu-conflict-jump]:focus-visible,[data-yanwu-conflict-group]:focus-visible,.yanwu-correction-return:focus-visible,[data-search-reset]:focus-visible,[data-portfolio-collect]:focus-visible{outline:3px solid #ac6c1e;outline-offset:3px}
.yanwu-correction-return{position:fixed;right:16px;bottom:calc(16px + env(safe-area-inset-bottom));z-index:50;max-width:calc(100vw - 32px);box-shadow:0 2px 8px #10251c33}
/* WebKit native menulists otherwise paint a light face under the dark header. */
.mobile-head select[data-mobile-page]{min-height:44px;-webkit-appearance:none;appearance:none;background-color:#202a25;color:#fff;padding-right:30px;background-image:linear-gradient(45deg,transparent 50%,#fff 50%),linear-gradient(135deg,#fff 50%,transparent 50%);background-position:calc(100% - 15px) 50%,calc(100% - 10px) 50%;background-size:5px 5px;background-repeat:no-repeat}
[data-mobile-page] option{background:#fff;color:#17251d}
