:root {
  color-scheme: light;
  --paper: #f5f4f0;
  --surface: #fff;
  --ink: #252820;
  --muted: #777a71;
  --line: #e7e6df;
  --green: #355a47;
  --green-dark: #284736;
  --accent: #c58361;
  font-family: "Yu Gothic UI", "Meiryo", sans-serif;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

html.auth-required body > :not(.auth-screen) { visibility: hidden; }
.auth-screen { position: fixed; z-index: 20; inset: 0; display: grid; place-items: center; overflow-y: auto; padding: 24px; background: var(--paper); }
.auth-screen[hidden] { display: none; }
.auth-card { width: min(440px, 100%); padding: 32px; border: 1px solid var(--line); border-radius: 15px; background: var(--surface); box-shadow: 0 12px 40px rgba(34, 39, 31, .07); }
.auth-brand { margin-bottom: 30px; }
.auth-card .eyebrow { margin-bottom: 10px; }
.auth-card h1 { font-size: clamp(24px, 5vw, 32px); line-height: 1.5; letter-spacing: .01em; }
.auth-card h1 span { color: var(--green); }
.auth-description { margin: 14px 0 22px; color: var(--muted); font-size: 12px; line-height: 1.8; }
.auth-card form { display: grid; gap: 10px; }
.auth-card form label { font-size: 11px; font-weight: 600; }
.auth-card input { width: 100%; min-height: 46px; padding: 0 12px; border: 1px solid #d8d9d0; border-radius: 7px; background: #fff; color: var(--ink); font: inherit; font-size: 16px; }
.auth-card input:focus { outline: 2px solid #93aa98; outline-offset: 1px; }
.auth-button { width: 100%; margin-top: 3px; }
.auth-button:disabled { opacity: .7; }
.auth-message { min-height: 20px; margin: 12px 0 0; color: #994c39; font-size: 11px; line-height: 1.7; }
.auth-message.is-success { color: var(--green); }
.auth-footnote { margin: 14px 0 0; color: #8c8d84; font-size: 10px; line-height: 1.8; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: "Yu Gothic UI", "Meiryo", sans-serif;
  -webkit-font-smoothing: antialiased;
}

.topbar {
  height: 74px;
  padding: 0 max(5.5vw, 28px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(37, 40, 32, .08);
}

.brand { color: inherit; text-decoration: none; display: flex; align-items: center; gap: 10px; }
.brand-mark { width: 35px; height: 35px; border-radius: 11px; display: grid; place-items: center; background: var(--green); color: #fff; font-family: "Yu Gothic UI", "Meiryo", sans-serif; font-size: 19px; }
.brand-name { font-family: "Yu Gothic UI", "Meiryo", sans-serif; font-weight: 700; font-size: 17px; letter-spacing: .06em; }
.brand-name small { display: block; margin-top: 1px; color: var(--muted); font: 600 8px Arial, sans-serif; letter-spacing: .2em; }
.local-note { display: flex; align-items: center; gap: 8px; color: #73766c; font-size: 11px; }
.privacy-dot { width: 7px; height: 7px; border-radius: 50%; background: #75a180; }

main { width: min(950px, calc(100% - 48px)); margin: 0 auto; }
.intro { text-align: center; padding: 57px 0 34px; }
.eyebrow { margin: 0 0 11px; color: var(--accent); font-size: 10px; font-weight: 700; letter-spacing: .18em; }
h1 { margin: 0; font-family: "Yu Gothic UI", "Meiryo", sans-serif; font-size: clamp(30px, 4vw, 43px); letter-spacing: .04em; line-height: 1.48; font-weight: 600; }
h1 span { color: var(--green); }
.intro-copy { margin: 14px 0 0; color: var(--muted); font-size: 13px; line-height: 1.9; }
.mobile-help { color: var(--green); font-size: 11px; line-height: 1.7; }

.workspace { padding: 26px 34px 30px; border: 1px solid #e8e7e1; border-radius: 15px; background: rgba(255,255,255,.72); box-shadow: 0 9px 35px rgba(34, 39, 31, .035); }
.steps { display: flex; align-items: center; justify-content: center; gap: 15px; margin-bottom: 25px; }
.step { display: flex; align-items: center; gap: 7px; color: #a3a49c; font-size: 11px; font-weight: 500; white-space: nowrap; }
.step span { color: #aaa99f; font: 600 10px Arial, sans-serif; }
.step.is-current, .step.is-done { color: var(--green); }
.step.is-current span, .step.is-done span { color: var(--green); }
.step-line { width: 38px; height: 1px; background: #e6e5de; }
.upload-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.upload-card { padding: 20px; border: 1px solid var(--line); border-radius: 11px; background: var(--surface); }
.card-heading { display: flex; align-items: center; gap: 10px; }
.card-icon { width: 34px; height: 34px; flex: 0 0 auto; display: grid; place-items: center; border-radius: 9px; font-family: "Yu Gothic UI", "Meiryo", sans-serif; font-size: 14px; font-weight: 600; }
.mono-icon { background: #f1f0ec; color: #65675e; }
.color-icon { background: #f8eee8; color: #b3704e; }
.card-kicker { margin: 0 0 2px; color: #9a9b91; font: 700 8px Arial, sans-serif; letter-spacing: .15em; }
.card-heading h2 { margin: 0; font: 600 13px "Yu Gothic UI", "Meiryo", sans-serif; letter-spacing: .015em; }
.file-count { margin-left: auto; color: #a0a197; font-size: 10px; white-space: nowrap; }
.card-description { margin: 12px 0 14px; color: var(--muted); font-size: 11px; }
.drop-area { min-height: 100px; display: flex; flex-direction: column; align-items: center; justify-content: center; border: 1px dashed #d8d9d0; border-radius: 8px; cursor: pointer; transition: background .2s, border-color .2s; }
.drop-area:hover, .drop-area:focus-within { border-color: #93aa98; background: #f6f8f5; }
.upload-symbol { width: 24px; height: 24px; display: grid; place-items: center; margin-bottom: 6px; border-radius: 50%; background: #f1f4ef; color: var(--green); font-size: 15px; }
.drop-title { font-size: 11px; font-weight: 600; }
.drop-subtitle { margin-top: 4px; color: #a0a197; font-size: 9px; }
.upload-actions { display: flex; justify-content: center; align-items: center; gap: 10px; padding-top: 11px; }
.text-button { color: var(--green); cursor: pointer; font-size: 10px; font-weight: 600; }
.text-button:hover { text-decoration: underline; }
.action-separator { color: #d3d2cb; font-size: 10px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.matching-bar { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding-top: 23px; }
.match-status { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 11px; line-height: 1.6; }
.status-mark { color: var(--accent); }
.primary-button { min-height: 44px; display: inline-flex; align-items: center; justify-content: center; gap: 17px; padding: 0 18px; border: 0; border-radius: 7px; background: var(--green); color: white; font: 600 11px "Yu Gothic UI", "Meiryo", sans-serif; cursor: pointer; transition: background .2s, transform .2s; white-space: nowrap; -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
.primary-button:not(:disabled):hover { background: var(--green-dark); transform: translateY(-1px); }
.primary-button:disabled { background: #b7bdb7; cursor: not-allowed; }
.primary-button span:last-child { font: 16px Arial, sans-serif; }
.error-message { margin-top: 15px; padding: 11px 13px; border: 1px solid #e9c9c0; border-radius: 7px; background: #fff6f3; color: #994c39; font-size: 11px; line-height: 1.7; }

.results { margin-top: 32px; }
.results-heading { display: flex; align-items: flex-end; justify-content: space-between; padding: 0 2px 14px; }
.results-heading .eyebrow { margin-bottom: 4px; }
.results-heading h2 { margin: 0; font: 600 21px "Yu Gothic UI", "Meiryo", sans-serif; }
.match-total { display: flex; align-items: baseline; gap: 7px; color: var(--muted); font-size: 11px; }
.match-total strong { color: var(--green); font-size: 24px; font-weight: 600; }
.results-note { margin: 0 0 14px; color: var(--muted); font-size: 11px; }
.pairing-help { margin: -5px 0 14px; color: #777a71; font-size: 10px; line-height: 1.7; }
.match-editors { margin-bottom: 14px; padding: 12px; border: 1px solid var(--line); border-radius: 9px; background: #fafaf8; }
.editor-mode-buttons { display: flex; gap: 8px; }
.editor-mode-button, .page-nav-button, .offset-step-button { min-height: 38px; padding: 0 12px; border: 1px solid #d8d9d0; border-radius: 6px; background: white; color: var(--ink); font: inherit; font-size: 10px; cursor: pointer; touch-action: manipulation; }
.editor-mode-button.is-active { border-color: var(--green); background: var(--green); color: white; }
.offset-editor { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 14px; margin-top: 12px; }
.offset-editor[hidden], .pair-list[hidden], .page-navigation[hidden] { display: none; }
.offset-editor > label { color: #66695f; font-size: 10px; font-weight: 600; }
.offset-editor > p { flex: 1 1 100%; margin: 0; color: var(--muted); font-size: 10px; line-height: 1.6; }
.offset-controls { display: flex; align-items: center; gap: 6px; }
.offset-step-button { min-width: 46px; color: var(--green); font-weight: 700; }
.offset-controls input { width: 76px; min-height: 38px; padding: 0 8px; border: 1px solid #d8d9d0; border-radius: 6px; background: white; color: var(--ink); font: inherit; font-size: 13px; text-align: center; }
.page-navigation { display: flex; align-items: center; justify-content: center; gap: 12px; margin: 14px 0; color: var(--muted); font-size: 10px; }
.page-nav-button:disabled { opacity: .5; cursor: not-allowed; }
.pair-list { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.pair-card { padding: 12px; border: 1px solid var(--line); border-radius: 9px; background: white; }
.pair-editor-card { min-width: 0; }
.pair-images { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
.pair-images img { width: 100%; height: 145px; object-fit: contain; background: #f4f3ef; border-radius: 5px; }
.pair-empty-preview { width: 100%; height: 145px; display: grid; place-items: center; border-radius: 5px; background: #f4f3ef; color: #929389; font-size: 11px; }
.pair-labels { display: flex; justify-content: space-between; gap: 8px; margin-top: 9px; color: var(--muted); font-size: 9px; }
.pair-labels span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pair-labels b { color: var(--green); font-weight: 600; }
.pair-selector-label { display: grid; gap: 6px; margin-top: 12px; color: #66695f; font-size: 10px; font-weight: 600; }
.pair-selector { width: 100%; min-width: 0; min-height: 38px; padding: 0 8px; border: 1px solid #d8d9d0; border-radius: 6px; background: white; color: var(--ink); font: inherit; font-size: 11px; }
.pair-selector:focus { outline: 2px solid #93aa98; outline-offset: 1px; }
.export-bar { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-top: 19px; padding: 18px 20px; border: 1px solid #dfe7df; border-radius: 10px; background: #f4f7f3; }
.export-bar h3 { margin: 0 0 4px; font: 600 12px "Yu Gothic UI", "Meiryo", sans-serif; }
.export-bar p { max-width: 560px; margin: 0; color: var(--muted); font-size: 10px; line-height: 1.7; }
.export-button { min-width: 190px; }

footer { display: flex; justify-content: space-between; gap: 15px; padding: 27px 2px 35px; color: #96978e; font-size: 9px; }
.footer-divider { padding: 0 4px; color: #c3c2b9; }
.ios-install-help { max-width: 290px; line-height: 1.7; }

@media (max-width: 700px) {
  body { padding-bottom: env(safe-area-inset-bottom); }
  .topbar { height: 62px; height: calc(62px + env(safe-area-inset-top)); padding: env(safe-area-inset-top) 18px 0; }
  .local-note { font-size: 9px; }
  main { width: min(100% - 32px, 510px); }
  .intro { padding: 34px 0 22px; }
  h1 { font-size: clamp(26px, 7.3vw, 36px); }
  .intro-copy { font-size: 11px; }
  .mobile-help:not([hidden]) { margin: 10px 0 0; }
  .desktop-break { display: none; }
  .workspace { padding: 20px 16px 22px; }
  .steps { gap: 8px; margin-bottom: 19px; }
  .step { gap: 4px; font-size: 9px; }
  .step-line { width: 16px; }
  .upload-grid { grid-template-columns: 1fr; gap: 11px; }
  .upload-card { padding: 16px; }
  .drop-area { min-height: 92px; padding: 10px; text-align: center; }
  .drop-title { font-size: 12px; }
  .drop-subtitle { font-size: 10px; }
  .upload-actions { min-height: 44px; }
  .text-button { display: inline-flex; min-height: 40px; align-items: center; padding: 0 8px; font-size: 11px; }
  .matching-bar { align-items: flex-start; flex-direction: column; }
  .matching-bar .primary-button { width: 100%; }
  .pair-list { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .pair-card { padding: 8px; }
  .pair-images img { height: 110px; }
  .pair-empty-preview { height: 110px; }
  .pair-selector { font-size: 10px; }
  .editor-mode-buttons { display: grid; grid-template-columns: 1fr 1fr; }
  .editor-mode-button { padding: 0 6px; font-size: 9px; }
  .offset-editor { align-items: flex-start; flex-direction: column; }
  .page-navigation { gap: 7px; }
  .page-nav-button { min-height: 40px; padding: 0 8px; }
  .export-bar { align-items: stretch; flex-direction: column; padding: 16px; }
  .export-button { width: 100%; }
  footer { flex-direction: column; gap: 7px; padding-top: 22px; padding-bottom: calc(22px + env(safe-area-inset-bottom)); }
  .auth-screen { align-items: start; padding: max(24px, env(safe-area-inset-top)) 16px max(24px, env(safe-area-inset-bottom)); }
  .auth-card { margin: auto 0; padding: 24px 20px; }
  .auth-brand { margin-bottom: 26px; }
}

@media (max-width: 390px) {
  .local-note { max-width: 150px; }
  .pair-list { grid-template-columns: 1fr; }
}
