:root {
  color-scheme: light;
  --ink: #3a2915;
  --muted: #7b6241;
  --paper: #fffdf4;
  --line: #f0c77a;
  --orange: #f28c28;
  --orange-dark: #bd6419;
  --orange-soft: #ffe8ad;
  --page-bg: #fff7dc;
  --grid-line: #f4dfad;
  --button-bg: #fffaf0;
  --shadow: 0 18px 48px rgba(128, 82, 22, .14);
  --base-font-size: 7mm;
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--page-bg); }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: "Yu Gothic UI", "Hiragino Sans", "Meiryo", sans-serif;
  font-size: var(--base-font-size);
  background:
    linear-gradient(rgba(244, 223, 173, .72) 1px, transparent 1px),
    linear-gradient(90deg, rgba(244, 223, 173, .72) 1px, transparent 1px),
    var(--page-bg);
  background-size: 24px 24px;
}
button, input, select { font: inherit; }
button { color: inherit; }
button:focus-visible, input:focus-visible, select:focus-visible { outline: 3px solid rgba(242, 140, 40, .34); outline-offset: 2px; }
.visually-hidden { position: absolute !important; width: 1px !important; height: 1px !important; padding: 0 !important; margin: -1px !important; overflow: hidden !important; clip: rect(0, 0, 0, 0) !important; white-space: nowrap !important; border: 0 !important; }

.app-shell { width: min(1540px, 100%); margin: 0 auto; padding: 26px 30px 42px; }
.app-header { display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; padding: 2px 4px 20px; }
.app-title-row { display: flex; align-items: center; gap: 16px; min-width: 0; }
.eyebrow, .step-label { margin: 0 0 5px; color: var(--orange); font-size: 11px; font-weight: 900; letter-spacing: .15em; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: clamp(18px, 4.5vw, 14mm); line-height: 1; letter-spacing: -.05em; white-space: nowrap; }
h1 span { color: var(--orange); font-weight: 800; }
.header-copy { margin: 0; color: var(--muted); font-size: var(--base-font-size); }
.language-picker { display: inline-flex; align-items: center; gap: 4px; margin-left: auto; color: var(--muted); font-size: 50%; font-weight: 800; white-space: nowrap; }
.language-picker select { width: auto; min-height: 24px; padding: 2px 5px; font-size: inherit; }


.workspace { display: grid; grid-template-columns: minmax(520px, 2.1fr) minmax(300px, .9fr); gap: 16px; align-items: stretch; }
.card { min-width: 0; border: 1px solid var(--line); border-radius: 22px; background: rgba(255,253,244,.95); box-shadow: var(--shadow); }
.control-panel { display: flex; min-height: 540px; flex-direction: column; overflow: hidden; }
.control-panel-content { padding: 22px; }
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.section-heading h2 { margin: 0; font-size: 18px; letter-spacing: -.03em; }
.step-label.mint { color: #397c70; }
.step-label.coral { color: #da5c55; }
.step-label.amber { color: #ab7411; }
.round-button { width: 34px; height: 34px; border: 1px solid var(--line); border-radius: 50%; background: white; cursor: pointer; font-size: 21px; line-height: 1; }
.round-button:hover { border-color: var(--orange); color: var(--orange); }

.desktop-tabs, .mobile-tabs { display: grid; gap: 0; }
.desktop-tabs { grid-template-columns: 1fr 1fr; border-bottom: 1px solid var(--line); background: #fffaf0; }
.mobile-tabs { display: none; }
.switch-tab { min-height: 48px; padding: 10px 12px; border: 0; border-bottom: 3px solid transparent; color: var(--muted); background: transparent; cursor: pointer; font-size: 13px; font-weight: 900; }
.switch-tab:hover { color: var(--orange-dark); background: #fff3cf; }
.switch-tab[aria-selected="true"] { border-bottom-color: var(--orange); color: var(--orange-dark); background: var(--orange-soft); }
.model-select-wrap { display: grid; gap: 8px; margin-top: 20px; color: var(--muted); font-size: 12px; font-weight: 900; }
.model-select-wrap select { border-color: #e5ad55; background: var(--button-bg); color: var(--ink); font-weight: 800; }
.model-select-wrap optgroup { color: var(--orange-dark); font-weight: 900; }
.model-select-wrap option { color: var(--ink); font-weight: 700; }
.model-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin: 20px 0 16px; }
.model-button { position: relative; min-height: 94px; padding: 10px 7px 8px; border: 1px solid var(--line); border-radius: 15px; background: #faf8f4; cursor: pointer; transition: .18s ease; }
.model-button:hover { transform: translateY(-2px); border-color: #ccbbaa; }
.model-button.active { border: 2px solid var(--orange); background: var(--orange-soft); box-shadow: 0 7px 20px rgba(233,117,66,.13); }
.model-button:disabled { cursor: not-allowed; opacity: .62; }
.model-button img { display: block; width: 48px; height: 48px; margin: 0 auto 4px; object-fit: contain; }
.model-button span { display: block; overflow: hidden; font-size: 11px; font-weight: 800; text-overflow: ellipsis; white-space: nowrap; }
.model-button.active::after { content: "✓"; position: absolute; top: 6px; right: 6px; display: grid; place-items: center; width: 18px; height: 18px; border-radius: 50%; color: white; background: var(--orange); font-size: 11px; }
.text-button { width: 100%; padding: 9px; border: 0; border-radius: 10px; color: #6e625a; background: #f1ede6; cursor: pointer; font-size: 12px; font-weight: 800; }
.text-button:hover { background: #e9e3db; }
.micro-copy { margin: 11px 0 0; color: #8b847d; font-size: 11px; line-height: 1.6; }
.fabric-usage { margin: 8px 0 0; color: #7b6241; font-weight: 800; }

.viewer-card { position: relative; z-index: 31; display: flex; flex-direction: column; height: clamp(540px, calc(100vh - 205px), 670px); min-height: 540px; overflow: visible; background-color: var(--viewer-bg, #ffffff); background-image: url("../img/haikei.png"); background-repeat: repeat; background-position: center; }
.viewer-card.viewer-color-background { background-image: none; }
.status-chip { max-width: 48%; padding: 7px 11px; overflow: hidden; border: 1px solid rgba(50,85,78,.13); border-radius: 999px; color: #557169; background: rgba(255,255,255,.74); font-size: 11px; font-weight: 800; text-overflow: ellipsis; white-space: nowrap; backdrop-filter: blur(6px); }
.status-chip.error { color: #a63f39; background: #fff0ee; }
.viewer { flex: 1; min-height: 0; overflow: hidden; border-radius: inherit; }
.viewer canvas { display: block; width: 100% !important; height: 100% !important; cursor: grab; }
.viewer canvas:active { cursor: grabbing; }
.light-wrap { position: absolute; top: 12px; right: 12px; z-index: 8; }
.light-button { width: 42px; height: 42px; padding: 7px; border-color: rgba(35,64,59,.14); background: rgba(255,255,255,.88); box-shadow: 0 5px 14px rgba(51,68,61,.14); backdrop-filter: blur(8px); }
.light-panel { position: absolute; top: 50px; right: 0; width: 196px; padding: 13px; border: 1px solid var(--line); border-radius: 14px; background: rgba(255,255,255,.97); box-shadow: 0 14px 35px rgba(45,39,32,.22); }
.light-panel[hidden] { display: none !important; }
.light-panel p { margin: 0 0 9px; font-size: 13px; }
.light-panel p span { display: block; margin-top: 2px; color: var(--muted); font-size: 10px; font-weight: 400; }
.light-options { display: grid; gap: 5px; }
.light-options label { display: flex; align-items: center; gap: 8px; min-height: 28px; padding: 3px 5px; border-radius: 7px; color: var(--ink); cursor: pointer; font-size: 12px; font-weight: 800; }
.light-options label:has(input:checked) { color: var(--orange-dark); background: var(--orange-soft); }
.light-options input { width: 15px; height: 15px; margin: 0; accent-color: var(--orange); }
.viewer-toolbar { position: absolute; left: 50%; bottom: 1mm; z-index: 5; display: flex; flex-wrap: nowrap; align-items: center; justify-content: center; gap: clamp(2px, 1vw, 7px); width: max-content; max-width: calc(100% - 26px); padding: clamp(4px, 1.2vw, 8px); border: 1px solid rgba(35,64,59,.12); border-radius: 16px; background: rgba(255,255,255,.88); box-shadow: 0 10px 25px rgba(51,68,61,.14); transform: translateX(-50%); backdrop-filter: blur(12px); }
.icon-button { display: grid; flex: 0 0 auto; place-items: center; width: 39px; height: 39px; padding: 7px; border: 1px solid transparent; border-radius: 10px; background: transparent; cursor: pointer; }
.icon-button:hover, .icon-button[aria-pressed="true"], .icon-button[aria-expanded="true"] { border-color: #e5ad55; background: #ffe8ad; }
.icon-button img { width: 100%; height: 100%; object-fit: contain; }
.toolbar-divider { flex: 0 0 auto; width: 1px; height: 27px; margin: 0 2px; background: #d9dedb; }
.background-wrap { position: relative; }
.background-button { padding: 8px; }
.background-swatch { display: block; width: 21px; height: 21px; border: 2px solid #b9b9b9; border-radius: 6px; background: #ffffff; box-shadow: inset 0 0 0 1px rgba(255,255,255,.75); }
.background-panel { position: absolute; left: -92px; bottom: 52px; width: 238px; padding: 15px; border: 1px solid var(--line); border-radius: 15px; background: white; box-shadow: 0 14px 35px rgba(45,39,32,.19); }
.background-panel p { margin: 0 0 12px; font-size: 13px; }
.background-panel p span { display: block; margin-top: 3px; color: var(--muted); font-size: 10px; font-weight: 400; }
.background-panel label { display: grid; grid-template-columns: 1fr 56px; align-items: center; gap: 8px; color: #5f5853; font-size: 12px; font-weight: 800; }
.background-panel input[type="color"] { width: 56px; height: 31px; padding: 2px; border: 1px solid var(--line); border-radius: 8px; background: white; }
.background-presets { display: grid; grid-template-columns: repeat(3, 1fr); gap: 5px; margin-top: 10px; }
.background-presets button { min-height: 30px; padding: 4px; border: 1px solid var(--line); border-radius: 7px; color: var(--ink); background: #fffaf0; cursor: pointer; font-size: 10px; font-weight: 800; }
.background-presets button:hover { background: var(--orange-soft); }
.palette-wrap { position: relative; z-index: 100; }
.palette-panel { position: absolute; right: -116px; bottom: 52px; z-index: 120; width: min(360px, calc(100vw - 28px)); max-height: min(500px, calc(100vh - 28px)); overflow-y: auto; padding: 18px; border: 1px solid var(--line); border-radius: 15px; background: white; box-shadow: 0 18px 42px rgba(45,39,32,.25); }
.palette-panel[hidden] { display: none !important; }
.palette-panel h2 { margin: 0; color: #322820; font-size: 20px; letter-spacing: -.03em; }
.mask-mode-row { display: flex; align-items: center; gap: 20px; margin: 15px 0 18px; }
.mask-mode-button { display: inline-flex; align-items: center; gap: 9px; padding: 4px 0; border: 0; color: #322820; background: transparent; cursor: pointer; font-size: 20px; font-weight: 900; }
.mask-mode-button::before { width: 17px; height: 17px; border: 2px solid #29231e; border-radius: 50%; content: ""; }
.mask-mode-button[aria-pressed="true"]::before { box-shadow: inset 0 0 0 4px white; background: #7663ef; }
.mask-color-picker { display: grid; flex: 0 0 auto; width: 62px; height: 62px; overflow: hidden; border: 1px solid rgba(35,31,27,.24); border-radius: 50%; background: #ffffff; cursor: pointer; box-shadow: 0 2px 5px rgba(35,31,27,.14); }
.mask-color-picker input { width: 100%; height: 100%; padding: 0; border: 0; background: transparent; cursor: pointer; }
.mask-color-picker input::-webkit-color-swatch-wrapper { padding: 0; }
.mask-color-picker input::-webkit-color-swatch { border: 0; border-radius: 50%; }
.mask-image-section { border-top: 1px solid #eee7dc; padding-top: 14px; }
.mask-image-section h3 { margin: 0 0 12px; color: #5f5853; font-size: 6.5px; }
.mask-slot-tabs { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; }
.mask-slot-tabs button { min-height: 31px; border: 1px solid var(--line); border-radius: 8px; color: #665e58; background: #fffaf3; cursor: pointer; font-size: 10px; font-weight: 900; }
.mask-slot-tabs button.active { color: #fff; border-color: var(--orange-dark); background: var(--orange); }
.mask-pattern-list { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 13px; max-height: 248px; overflow: auto; padding: 2px; }
.mask-pattern-choice { display: grid; min-width: 0; aspect-ratio: 1; padding: 3px; border: 3px solid transparent; border-radius: 50%; background: transparent; cursor: pointer; }
.mask-pattern-choice img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }
.mask-pattern-choice.active { border-color: #e9c636; box-shadow: 0 0 0 4px rgba(255,229,98,.35); }
.palette-actions { display: flex; justify-content: flex-end; margin-top: 18px; }
.palette-actions .button { min-width: 84px; min-height: 35px; padding: 6px 16px; background: #8c7560; font-size: 13px; }
.palette-actions .button:hover { background: #6f5a49; }
.mask-button { flex: 0 1 auto; min-width: 0; height: 37px; padding: 0 clamp(3px, 1.7vw, 10px); overflow: hidden; border: 1px solid #d8d7d4; border-radius: 10px; background: #fafafa; cursor: pointer; font-size: clamp(7px, 3vw, 11px); font-weight: 900; text-overflow: ellipsis; white-space: nowrap; }
.mask-button[aria-pressed="true"] { border-color: var(--orange); color: white; background: var(--orange); }
.viewer-note { position: absolute; right: 18px; bottom: calc(1mm + 58px); left: 18px; margin: 0; color: #65756f; font-size: 11px; text-align: center; }

.upload-zone { display: grid; place-items: center; min-height: 162px; margin-top: 19px; padding: 18px; border: 2px dashed #e5ad55; border-radius: 17px; background: #fffaf0; cursor: pointer; transition: .18s ease; text-align: center; }
.upload-zone:hover { border-color: var(--orange); background: var(--orange-soft); }
.upload-zone input { position: absolute; left: 0; width: 1px !important; min-height: 1px; height: 1px; padding: 0; overflow: hidden; opacity: 0; }
.upload-zone strong { margin-top: 7px; font-size: 14px; }
.upload-zone small { margin-top: 3px; color: var(--muted); font-size: 10px; }
.upload-icon { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%; color: white; background: var(--orange); font-size: 25px; }
.button { min-height: 40px; padding: 9px 15px; border: 1px solid transparent; border-radius: 11px; cursor: pointer; font-weight: 900; }
.button:disabled { cursor: not-allowed; opacity: .45; }
.button.primary { color: white; background: var(--orange); }
.button.primary:hover { background: var(--orange-dark); }
.button.secondary { border-color: var(--line); background: white; }
.button.secondary:hover { background: #f6f2ec; }
.button.wide { width: 100%; margin-top: 10px; font-size: 12px; }
.material-box { margin-top: 24px; padding-top: 19px; border-top: 1px solid var(--line); }
.material-box label { display: block; margin-bottom: 8px; font-size: 14px; font-weight: 900; }
select, input[type="text"], input[type="number"], input[type="file"] { width: 100%; min-height: 42px; padding: 8px 10px; border: 1px solid #d9d2ca; border-radius: 10px; background: white; }

.app-dialog { width: min(1120px, calc(100% - 28px)); max-height: calc(100vh - 32px); padding: 0; overflow: auto; border: 0; border-radius: 22px; background: var(--paper); box-shadow: 0 25px 80px rgba(31,27,22,.28); }
.app-dialog::backdrop { background: rgba(38,34,31,.53); backdrop-filter: blur(3px); }
.dialog-shell { padding: 26px; }
.dialog-heading { display: flex; justify-content: space-between; gap: 20px; }
.dialog-heading h2 { margin: 0; font-size: 23px; }
.dialog-close { width: 38px; height: 38px; border: 0; border-radius: 50%; background: #eee9e3; cursor: pointer; font-size: 22px; }
.dialog-lead { margin: 11px 0 20px; color: var(--muted); font-size: 13px; line-height: 1.7; }
.correction-grid { display: grid; grid-template-columns: 1.25fr 1fr; gap: 14px; }
.canvas-card { min-width: 0; padding: 12px; border: 1px solid var(--line); border-radius: 15px; background: #f9f7f3; }
.canvas-label { display: flex; justify-content: space-between; margin-bottom: 9px; color: var(--muted); font-size: 11px; }
.canvas-label b { color: var(--ink); font-size: 13px; }
.canvas-card canvas { display: block; width: 100%; height: auto; max-height: 52vh; border-radius: 10px; background: #eee; touch-action: none; }
.corner-legend { display: flex; flex-wrap: wrap; gap: 8px 14px; margin-top: 8px; color: var(--muted); font-size: 10px; }
.size-row { display: grid; grid-template-columns: 1fr 1fr auto auto; align-items: end; gap: 10px; margin-top: 15px; }
.size-row label, .model-form-grid label { color: #5d5752; font-size: 12px; font-weight: 800; }
.size-row label > span, .input-unit { display: flex; align-items: center; gap: 7px; margin-top: 5px; }
.size-row input { width: 100%; }
.form-message { min-height: 18px; margin: 10px 0 0; color: #317063; font-size: 12px; }
.form-message.error { color: #b23e36; }

.model-dialog { width: min(780px, calc(100% - 28px)); }
.model-form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; }
.model-form-grid label > input, .model-form-grid label > select { margin-top: 6px; }
.model-form-grid small { color: var(--muted); font-weight: 400; }
.model-form-grid .check-row { display: flex; align-items: center; gap: 9px; min-height: 42px; }
.check-row input { width: 17px; height: 17px; }
.mask-guide { display: flex; flex-wrap: wrap; gap: 10px 18px; margin-top: 20px; padding: 13px; border-radius: 12px; background: #f5f2ec; color: #615b55; font-size: 11px; }
.mask-guide span { display: flex; align-items: center; gap: 5px; }
.mask-dot { display: inline-block; width: 11px; height: 11px; border: 1px solid rgba(0,0,0,.14); border-radius: 50%; }
.mask-dot.red { background: #e52323; }.mask-dot.blue { background: #2678e0; }.mask-dot.black { background: #181818; }.mask-dot.magenta { background: #e400a8; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 18px; }

.account-card { position: fixed; right: 18px; bottom: 16px; z-index: 30; width: min(330px, calc(100vw - 36px)); padding: 15px 16px 14px; border: 1px solid rgba(216, 196, 180, .95); border-radius: 17px; color: #554b44; background: rgba(255, 250, 244, .96); box-shadow: 0 13px 34px rgba(52, 42, 33, .18); backdrop-filter: blur(10px); }
html.settings-mode .workspace { display: none; }
html.settings-mode #trialNotice { display: none !important; }
html.settings-mode #accountCard { position: relative; right: auto; bottom: auto; width: min(620px, calc(100vw - 36px)); margin: 10px auto 90px; z-index: 32; }
.account-card-heading { display: flex; align-items: center; gap: 8px; }
.account-badge { color: #c45e32; font-size: 10px; font-weight: 900; letter-spacing: .14em; }
.usage-label { margin-left: auto; color: #796c62; font-size: 11px; font-weight: 800; }
.account-card-close { display: grid; width: 26px; height: 26px; place-items: center; padding: 0; border: 0; border-radius: 50%; color: #766960; background: transparent; cursor: pointer; font-size: 20px; line-height: 1; }
.account-card-close:hover, .account-card-close:focus-visible { color: #554b44; background: #eee9e3; }
.account-copy { margin: 8px 0 11px; color: #61574f; font-size: 11px; line-height: 1.7; }
.settings-intro { margin-top: 0; }
.settings-intro a { color: #a95732; font-weight: 900; }
.settings-session-note { padding-top: 12px; border-top: 1px solid #eaded3; }
.trial-notice { z-index: 31; }
.trial-notice > .account-card-close { float: right; margin: -3px -4px 0 8px; }
.trial-notice .account-copy { font-size: 60% !important; }
.trial-notice-close { display: block; width: 100%; margin-top: 10px; font-size: 60% !important; }
.trial-notice hr { margin: 12px 0; border: 0; border-top: 1px solid #eaded3; }
.trial-notice-plan { margin-bottom: 0; }
.trial-notice a { color: #a95732; font-weight: 900; }
.account-login-button, .google-login-button { width: 100%; min-height: 40px; border: 0; border-radius: 10px; color: white; background: #4385e1; cursor: pointer; font-weight: 900; }
.account-login-button:hover, .google-login-button:hover { background: #3473cb; }
.account-login-button.logged-in { color: #37675d; background: #e5f2ed; }
.account-logout-button { width: 100%; min-height: 34px; margin-top: 7px; border: 1px solid #d9d2ca; border-radius: 10px; color: #6b5a51; background: white; cursor: pointer; font-size: 12px; font-weight: 800; }
.account-logout-button:hover { background: #f6f2ec; }
.account-admin-button { display: grid; width: 100%; min-height: 34px; place-items: center; margin-top: 7px; border: 1px solid #d9d2ca; border-radius: 10px; color: #6b5a51; background: white; cursor: pointer; font-size: 12px; font-weight: 800; text-decoration: none; }
.account-admin-button:hover { background: #f6f2ec; }
.fanbox-access { margin-top: 12px; padding-top: 11px; border-top: 1px solid #eaded3; }
.fanbox-access > p:first-child { margin: 0 0 8px; color: #61574f; line-height: 1.6; }
.fanbox-access a { color: #a95732; font-weight: 900; }
.fanbox-access label { display: block; margin-bottom: 5px; color: #6b5a51; font-weight: 800; }
.fanbox-password-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 7px; }
.fanbox-password-row input { min-width: 0; }
.fanbox-password-row .button { min-height: 42px; white-space: nowrap; }
.fanbox-access .form-message { margin-top: 6px; }
.member-area { margin-top: 12px; padding-top: 11px; border-top: 1px solid #eaded3; }
.member-greeting { margin: 0 0 7px; color: #3d6f64; font-size: 12px; font-weight: 900; }
.member-area .button.wide { margin-top: 0; }
.member-note { margin: 6px 0 10px; color: #8a7a70; font-size: 10px; }
.fanbox-plans { display: grid; gap: 4px; color: #6b5a51; font-size: 10px; line-height: 1.45; }
.fanbox-plans b { color: #ad5a36; font-size: 11px; }
.account-message { min-height: 15px; margin: 8px 0 0; color: #ad5a36; font-size: 10px; line-height: 1.5; }
.account-message.success { color: #367467; }
.auth-dialog { width: min(430px, calc(100% - 28px)); }
.google-login-button { margin-top: 4px; }
.auth-dialog .dialog-actions { margin-top: 14px; }
.app-icon-nav { position: fixed; z-index: 28; right: 18px; top: 50%; display: grid; gap: 8px; transform: translateY(-50%); }
.app-nav-button { position: relative; display: grid; place-items: center; width: 64px; min-height: 64px; padding: 9px; border: 1px solid rgba(216, 196, 180, .95); border-radius: 14px; color: #735d51; background: rgba(255,250,244,.96); box-shadow: 0 6px 15px rgba(52,42,33,.11); cursor: pointer; text-decoration: none; }
.app-nav-button img { width: 42px; height: 42px; object-fit: contain; }
.app-nav-button.active, .app-nav-button:hover { border-color: #e3a43c; background: #fff0c3; }
.app-nav-button::after { content: attr(data-tooltip); position: absolute; top: 50%; right: calc(100% + 10px); z-index: 1; padding: 6px 9px; border-radius: 7px; color: #fff; background: rgba(58, 41, 21, .92); box-shadow: 0 4px 12px rgba(52,42,33,.18); font-size: 12px; font-weight: 800; line-height: 1; white-space: nowrap; pointer-events: none; opacity: 0; transform: translate(4px, -50%); transition: opacity .15s ease, transform .15s ease; }
.app-nav-button:hover::after, .app-nav-button:focus-visible::after { opacity: 1; transform: translate(0, -50%); }

@media (max-width: 1100px) {
  .app-shell { padding: 20px; }
  .workspace { grid-template-columns: minmax(430px, 1.65fr) minmax(270px, .9fr); }
  .upload-zone { min-height: 135px; margin-top: 0; }
  .material-box { margin-top: 20px; }
}

@media (max-width: 760px) {
  .app-shell { padding: 14px 12px 30px; }
  .app-header { padding-bottom: 15px; }
  .app-title-row { align-items: center; gap: 7px; }
  .language-picker { flex: 0 0 auto; flex-direction: row; align-items: center; gap: 5px; }
  .header-copy { display: none; }
  .workspace { display: flex; flex-direction: column; }
  .mobile-tabs { display: grid; grid-template-columns: repeat(3, 1fr); order: 1; border: 1px solid var(--line); border-radius: 14px; overflow: hidden; background: #fffdf4; }
  .mobile-tabs .switch-tab { min-height: 44px; padding: 7px 4px; overflow: hidden; font-size: clamp(8px, 3.2vw, 11px); letter-spacing: -.08em; text-overflow: ellipsis; white-space: nowrap; }
  .control-panel { order: 2; min-height: 0; border-radius: 18px; }
  .viewer-card { order: 3; height: auto; min-height: 570px; }
  .control-panel-content { padding: 18px; }
  .desktop-tabs { display: none; }
  .workspace[data-mobile-tab="preview"] .control-panel { display: none; }
  .workspace:not([data-mobile-tab="preview"]) .viewer-card { display: none; }
  .control-panel .upload-zone { margin-top: 18px; }
  .material-box { padding-top: 18px; border-top: 1px solid var(--line); }
  .viewer-toolbar { gap: clamp(2px, 1vw, 3px); padding: clamp(4px, 1.8vw, 6px); }
  .icon-button { width: 35px; height: 35px; padding: 6px; }
  .mask-button { padding: 0 clamp(3px, 1.7vw, 6px); font-size: clamp(7px, 3vw, 9px); }
  .palette-panel { right: -90px; width: min(360px, calc(100vw - 20px)); }
  .background-panel { left: -110px; width: 230px; }
  .correction-grid, .model-form-grid { grid-template-columns: 1fr; }
  .size-row { grid-template-columns: 1fr 1fr; }
  .dialog-shell { padding: 19px; }
  .account-card { position: static; width: auto; margin: 12px 12px 20px; }
  .app-icon-nav { position: sticky; right: auto; top: auto; bottom: 0; grid-template-columns: repeat(4, 1fr); width: 100%; padding: 7px 12px calc(7px + env(safe-area-inset-bottom)); transform: none; background: rgba(255,250,244,.95); box-shadow: 0 -5px 18px rgba(52,42,33,.10); }
  .app-nav-button { width: auto; min-height: 64px; border-radius: 12px; box-shadow: none; }
  .app-nav-button::after { top: auto; right: auto; bottom: calc(100% + 9px); left: 50%; transform: translate(-50%, 4px); }
  .app-nav-button:hover::after, .app-nav-button:focus-visible::after { transform: translate(-50%, 0); }
}

@media (max-width: 430px) {
  h1 { font-size: clamp(18px, 4.5vw, 27px); }
  .control-panel-content { padding: 18px; }
  .viewer-card { min-height: 520px; }
  .viewer { min-height: 510px; }
  .viewer-toolbar { bottom: 1mm; }
  .icon-button:nth-child(3), .icon-button:nth-child(4) { display: none; }
  .size-row { grid-template-columns: 1fr; }
}

html.embed-mode body { min-height: 0; }
html.embed-mode .app-header { display: none; }
html.embed-mode .app-shell { width: 100%; padding: 0; }
html.embed-mode .workspace { gap: 10px; }
html.embed-mode .card { border-radius: 14px; box-shadow: none; }
html.embed-mode .account-card { right: 10px; bottom: 10px; }

/* 利用者が読む文字は、画面やダイアログを含めて7mmを基本にする。フォームのラベルと選択欄は個別のpx指定を優先する。 */
.app-shell :is(h2, h3, button:not(.icon-button), input, output),
.account-card :is(span, button, input, output),
.app-icon-nav :is(span, button, a),
.app-dialog :is(h2, h3, button, input, output) {
  font-size: var(--base-font-size) !important;
}

/* 説明文は読みやすい16pxにそろえる。 */
.app-shell :is(p, small),
.account-card :is(p, small),
.app-dialog :is(p, small) { font-size: 16px !important; }

/* ラベル・選択欄には7mmの共通指定をかけず、各部品の指定を使う。指定がないものは16px。 */
:where(.app-shell, .account-card, .app-dialog) :where(label) { font-size: 16px; }
:where(.app-shell, .account-card, .app-dialog) select { font-size: 16px; }
.app-shell .model-select-wrap select { font-size: inherit; }

/* 右上の表示言語は、表示名と選択欄をともに14pxにする。 */
.app-shell .language-picker,
.app-shell .language-picker :is(.language-picker-label, select) { font-size: 14px !important; }

/* 上部タブは常に一行。画面幅に合わせて縮小して収める。 */
.app-shell .switch-tab { min-width: 0; overflow: hidden; font-size: clamp(11px, 2.1vw, 16px) !important; line-height: 1.15; text-overflow: clip; white-space: nowrap; }
@media (max-width: 760px) {
  .app-shell .mobile-tabs .switch-tab { font-size: clamp(9.5px, 3.25vw, 14px) !important; }
}
.model-button span { overflow: visible; text-overflow: clip; white-space: normal; }
.account-card { width: min(520px, calc(100vw - 36px)); }
