/* 上部バー・ツールバー・通知バー・ワークスペースの枠組み。 */
/* Keep the Desktop workspace: operator list on the left, collapsible materials on the right. */
.app-shell .penguin-modal {
    width: min(520px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); box-sizing: border-box;
    color: var(--text); background: var(--panel); border-color: var(--line);
    border-radius: var(--bevel-frame); corner-shape: bevel; box-shadow: none;
}
.app-shell .penguin-modal h2 { margin: 0 0 16px; font-size: 16px; }
.app-shell .penguin-copy { width: 100%; white-space: normal; }
.app-shell .penguin-modal p { margin: 12px 0 0; }
.app-shell .penguin-modal-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-top: 16px; }
.app-shell { width: 100%; overflow-x: hidden; }
.main-workspace {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(20rem, 28rem);
    gap: .6rem;
    align-items: start;
    min-width: 0;
}
.main-workspace.materials-collapsed .material-pane { display: none; }
.operator-pane, .material-pane { min-width: 0; }
.app-shell .ak-notifbar {
    position: fixed;
    inset: auto 0 0;
    z-index: 45;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    min-height: 38px;
    padding: 0 12px;
    background: var(--chrome);
    border-top: 1px solid var(--chrome-line);
    color: var(--mute2);
    font-size: 11px;
}
.app-shell .ak-notif { display: flex; align-items: center; gap: 8px; min-width: 0; overflow: hidden; white-space: nowrap; }
.app-shell .ak-notif + .ak-notif { border-left: 1px solid var(--line); padding-left: 12px; }
.app-shell .ak-notif span { overflow: hidden; text-overflow: ellipsis; }
.app-shell .ak-notif strong { color: var(--accent); font: 600 10px var(--font-display); }
.app-shell .ak-notif-w2 small { margin-left: auto; color: var(--mute); font: 10px var(--font-mono); }
.app-shell .ak-notif-train-track { display: inline-block; width: 80px; height: 4px; background: var(--line); }
.app-shell .ak-notif-train-track span { display: block; height: 100%; background: var(--accent); }
.app-shell .ak-topbar {
    display: flex;
    align-items: center;
    gap: 6px;
    min-height: 44px;
    padding: 4px 10px;
}
.app-shell .ak-topbar h1 { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.app-shell .ak-topbar-spacer { flex: 1 1 auto; }
.app-shell .ak-topbar-icon {
    min-width: 36px;
    min-height: 34px;
    padding: 0;
    font-size: 16px;
    line-height: 1;
}
.app-shell .ak-nav-backdrop { position: fixed; inset: 0; z-index: 90; background: #0008; }
.app-shell .ak-nav-drawer {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 91;
    display: flex;
    flex-direction: column;
    flex-wrap: nowrap;
    align-items: stretch;
    gap: 0;
    width: min(300px, 86vw);
    text-align: left;
    margin: 0;
    padding: 8px;
    overflow-y: auto;
    background: var(--panel2);
    border-right: 1px solid var(--line2);
    box-shadow: 12px 0 32px #000a;
}
.app-shell .ak-nav-drawer:focus { outline: none; }
.app-shell .ak-nav-group { margin: 12px 6px 4px; color: var(--accent); font: 600 11px var(--font-display); letter-spacing: .06em; }
.app-shell .ak-nav-group:first-child { margin-top: 4px; }
.app-shell .ak-nav-label { margin: 6px 8px 4px; color: var(--mute2); font-size: 11px; }
.app-shell .ak-nav-item {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    min-height: 40px;
    padding: 0 10px;
    border: 0;
    color: var(--text);
    background: transparent;
    text-align: left;
    font-size: 13px;
}
.app-shell .ak-nav-item:hover { background: var(--accent-soft); }
.app-shell .ak-nav-check { cursor: pointer; }
.app-shell .ak-nav-seg { display: flex; gap: 2px; margin: 0 6px 6px; }
.app-shell .ak-nav-seg button { flex: 1 1 0; min-height: 34px; padding: 0 6px; }
/* 選択中の文字は --text3 の太字。--accent を文字色にするとライト系テーマの --accent-soft 上で 4.5:1 を割る(#695)。 */
.app-shell .ak-nav-seg button.is-checked { color: var(--text3); font-weight: 600; background: var(--accent-soft); border-color: var(--btn-accent-line); }
/* テーマは6つ。上段にダーク系、下段にライト系が並ぶよう3列で折り返す。 */
.app-shell .ak-nav-seg.ak-nav-themes { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.app-shell .ak-nav-gauge { padding: 0 6px; }
.app-shell .ak-nav-gauge .ownership-gauge { flex-wrap: wrap; }
/* 一括入力・折りたたみはスマホだけ、所持率はスマホ・タブレットの ☰ に出す (responsive.css、#733)。 */
.app-shell .ak-nav-narrow { display: none; }
.app-shell .ak-nav-ownership { display: none; }
.app-shell .workspace-nav {
    display: flex;
    flex: 0 0 auto;
    margin: 0;
    padding: 0;
    gap: 2px;
}
@media (min-width: 1280px) { .app-shell .workspace-nav { display: none; } }
/* アカウント選択(#624)。PC 幅では上部バー、1279px 以下は ☰ の「アカウント」で同じ操作をする。
   閾値は狭幅の区分(responsive.css・js/viewport-tier.js)と同じ値に揃える。 */
.app-shell .ak-account { display: flex; align-items: center; gap: 6px; min-width: 0; }
.app-shell .ak-account-label { color: var(--dim2); font: 600 10px var(--font-display); letter-spacing: .12em; }
.app-shell .dd-trigger.ak-account-select { width: 180px; min-height: 34px; font-size: 12.5px; }
.app-shell .ak-nav-account { display: none; }
.app-shell .ak-nav-account-select { margin: 0 6px 6px; }
.app-shell .ak-nav-account-select .dd-trigger.ak-account-select { width: 100%; }
/* NavDrawer 内の通常要素より手前に選択肢を描く。開いている間だけ上げ、他の backdrop を越えない。 */
.app-shell .ak-nav-account-select .dd-backdrop { z-index: 91; }
.app-shell .ak-nav-account-select .dd-popup { z-index: 92; }
@media (max-width: 1279px) {
    .app-shell .ak-topbar .ak-account { display: none; }
    .app-shell .ak-nav-account { display: block; }
}
.app-shell .account-modal h2 { margin: 0 0 8px; font-size: 15px; }
.app-shell .account-modal p { margin: 0 0 14px; line-height: 1.5; }
.app-shell .account-modal-actions { display: flex; justify-content: flex-end; gap: 8px; }
.app-shell .browser-modal.account-management {
    width: min(520px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); box-sizing: border-box;
    color: var(--text); background: var(--panel); border-color: var(--line);
    border-radius: var(--bevel-frame); corner-shape: bevel; box-shadow: none; font-size: 16px;
}
.app-shell .account-management-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.app-shell .account-management-heading h2 { margin: 0; font: inherit; font-weight: 600; color: var(--text); }
.app-shell .account-management-list { display: flex; flex-direction: column; gap: 8px; }
.app-shell .account-management-row { display: grid; grid-template-columns: 4.5em minmax(0, 1fr) auto; align-items: center; gap: 8px; font-size: 13px; }
.app-shell .account-management-status { min-width: 0; min-height: 1em; color: var(--accent); font-size: 11px; white-space: nowrap; }
.app-shell .account-name-input {
    width: 100%; min-width: 0; height: 32px; box-sizing: border-box; padding: 4px 8px;
    font-size: 13px; background: var(--input); border: 1px solid var(--line2);
    border-radius: var(--bevel-control); corner-shape: bevel; color: var(--text);
}
.app-shell .account-management button { font-size: 12px; white-space: nowrap; }
.app-shell .account-management-footer { justify-content: space-between; margin-top: 16px; }
/* 削除の OK は赤。文字色はテーマごとに赤面との 4.5:1 を満たす側を選ぶ(dark の赤は明るいので濃い文字)。 */
.app-shell .account-modal button.account-danger { color: #160B02; background: var(--danger); border-color: var(--danger); }
.app-shell .account-modal button.account-danger:hover { background: var(--danger); filter: brightness(1.08); }
.app-shell[data-theme="light"] .account-modal button.account-danger { color: #FFFFFF; }
.app-shell .workspace-nav button {
    height: 32px;
    padding: 0 12px;
    border: 1px solid transparent;
    background: transparent;
    color: var(--mute);
    font-size: 12px;
}
.app-shell .workspace-nav button:hover { color: var(--text); background: var(--btn-hover-bg); }
.app-shell .workspace-nav button.active {
    background: var(--accent-soft);
    color: var(--accent);
    border-color: var(--accent-soft-line);
}
.app-shell .toolbar { gap: 8px; }
.app-shell .main-toolbar {
    flex: 0 0 auto;
    position: relative;
    z-index: 51;
    min-height: 58px;
    margin: 0;
    padding: 8px 16px;
    background: var(--tool);
    border-bottom: 1px solid var(--tool-line);
}
.app-shell .main-toolbar label { color: var(--mute2); }
.app-shell .main-toolbar input[type=search] { width: min(280px, 42vw); }
.app-shell .ak-search { display: flex; align-items: center; gap: 5px; min-height: 34px; padding: 0 6px; border: 1px solid var(--line2); background: var(--input); }
.app-shell .ak-search svg { width: 16px; height: 16px; flex: 0 0 16px; color: var(--mute2); }
.app-shell .ak-search input[type=search] { width: min(240px, 31vw); min-width: 0; padding: 4px; border: 0; background: transparent; }
.app-shell .ak-kbd, .app-shell .ak-search-count { color: var(--mute2); white-space: nowrap; font: 10px var(--font-mono); }
.app-shell .ak-search button { min-height: 22px; height: 22px; padding: 0 5px; border: 0; background: transparent; }
/* 件数の桁が変わっても前後移動のボタンが動かないよう、幅を確保して右に寄せる。 */
.app-shell .ak-search-count { min-width: 3.5em; text-align: right; }
.app-shell .ak-search .ak-search-step { font-size: 10px; }
.app-shell .main-toolbar > span {
    padding: 5px 9px;
    border: 1px solid var(--accent-soft-line);
    border-radius: 20px;
    color: var(--accent);
    background: var(--accent-soft);
    font: 600 11px var(--font-mono);
}
.app-shell .toolbar-search, .app-shell .toolbar-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.app-shell .toolbar-actions { margin-left: auto; }
.app-shell .toolbar-actions > span {
    padding: 5px 9px;
    border: 1px solid var(--accent-soft-line);
    border-radius: 20px;
    color: var(--accent);
    background: var(--accent-soft);
    font: 600 11px var(--font-mono);
}
.app-shell .ownership-gauge {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 5px 12px;
    background: var(--card);
    border: 1px solid var(--card-line);
    border-radius: var(--bevel-container);
    corner-shape: bevel;
}
.app-shell .ownership-gauge > strong { color: var(--dim2); font: 600 10px var(--font-display); letter-spacing: .12em; white-space: nowrap; }
.app-shell .ownership-gauge-row { display: flex; align-items: center; gap: 5px; white-space: nowrap; }
.app-shell .ownership-gauge-row > span { color: var(--mute2); font-size: 10px; }
.app-shell .ownership-gauge-track { width: 76px; height: 5px; overflow: hidden; background: var(--line); border-radius: 3px; }
.app-shell .ownership-gauge-track > span { display: block; height: 100%; background: var(--accent); }
.app-shell .ownership-gauge-row b { color: var(--text2); font: 600 10px var(--font-display); }
.app-shell .ownership-gauge-row em { color: var(--accent); font: 600 10px var(--font-display); font-style: normal; }
.app-shell .main-workspace { flex: 1 1 auto; min-height: 0; overflow: hidden; align-items: stretch; gap: 0; grid-template-columns: minmax(0, 1fr) calc(35rem + 22px); }
/* 本体の既存幅を保って操作列(14px)と間隔(8px)を足す。折りたたみ時も列を窓端に残す (#730)。 */
.app-shell .material-side { display: flex; justify-content: flex-end; gap: 8px; min-width: 0; min-height: 0; margin: 12px 16px 12px 0; }
.app-shell .material-side .material-pane { flex: 1 1 auto; margin: 0; }
.app-shell .mat-rail { flex: 0 0 14px; width: 14px; min-height: 0; display: flex; flex-direction: column; gap: 8px; }
.app-shell .mat-pos { flex: 0 0 auto; height: 28px; min-height: 28px; }
.app-shell .mat-strip { flex: 1 1 auto; min-height: 0; }
.app-shell :is(.mat-strip, .mat-pos) {
    width: 14px; min-width: 14px; padding: 0; display: flex; align-items: center; justify-content: center;
    color: var(--mute); background: var(--btn-bg); border: 1px solid var(--btn-line);
    border-radius: var(--bevel-control); corner-shape: bevel; cursor: pointer;
}
.app-shell :is(.mat-strip, .mat-pos):hover { background: var(--btn-hover-bg); border-color: var(--btn-hover-line); }
.app-shell .mat-strip-icon { width: 10px; height: 10px; flex: none; }
/* 素材欄の左置き (#718)。DOM 順は一覧 → 素材欄のまま order で入れ替えるので Tab 順は左右で変わらない。
   折りたたみ規則と同じ詳細度のため、その前に置く。.materials-left は C# が PC 幅でだけ付けるが、
   幅を狭めた直後は区分の通知が届くまで残るので、狭幅の規則を上書きしないよう PC 幅に限る
   (閾値は responsive.css / js/viewport-tier.js の狭幅 1279px の裏)。 */
@media (min-width: 1280px) {
    .app-shell .main-workspace.materials-left { grid-template-columns: calc(35rem + 22px) minmax(0, 1fr); }
    .app-shell .main-workspace.materials-left .material-side { order: -1; margin: 12px 0 12px 16px; flex-direction: row-reverse; }
    .app-shell .main-workspace.materials-left .mat-strip-chevron { transform: scaleX(-1); }
    .app-shell .main-workspace.materials-left .operator-layout { padding: 12px 16px 12px 12px; }
    .app-shell .main-workspace.materials-left.materials-collapsed { grid-template-columns: 38px minmax(0, 1fr); }
    /* 通知も素材欄と同じ側へ寄せる: W2(保存・訓練室)を左、W1 を右に並べ、区切り線は右側の欄に引く。 */
    .app-shell:has(.main-workspace.materials-left) .ak-notif-w2 { order: -1; border-left: 0; padding-left: 0; }
    .app-shell:has(.main-workspace.materials-left) .ak-notif-w1 { border-left: 1px solid var(--line); padding-left: 12px; }
}
.app-shell .main-workspace.materials-collapsed:not(.materials-left) { grid-template-columns: minmax(0, 1fr) 38px; }
.app-shell .operator-pane { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.app-shell .operator-pane:has(.browser-sheet) { position: relative; z-index: 50; }
.app-shell .operator-layout { display: flex; flex-direction: column; flex: 1 1 auto; min-height: 0; padding: 12px 12px 12px 16px; }
/* 操作の結果を短く知らせる(入手リストへの追加・保存) (#619)。 */
.app-shell .ak-toast {
    position: fixed;
    left: 50%;
    bottom: 56px;
    z-index: 120;
    transform: translateX(-50%);
    max-width: min(92vw, 520px);
    padding: 10px 16px;
    color: var(--text3);
    background: var(--card);
    border: 1px solid var(--btn-accent-line);
    box-shadow: 0 8px 24px #000a;
    font-size: 13px;
}
.app-shell .ak-badge { display: inline-block; min-width: 18px; margin-left: 6px; padding: 0 5px; border-radius: 9px; corner-shape: round; color: var(--accent-ink); background: var(--accent); font-size: 11px; line-height: 18px; text-align: center; }
