@import url("https://fonts.googleapis.com/css2?family=Zen+Kaku+Gothic+New:wght@400;500;700;900&display=swap");
:root {
  --bg-1: #fdf2e7;
  --bg-2: #fbe9d8;
  --panel: #ffffff;
  --border: #efe2d2;
  --border-strong: #e3c9aa;
  --text: #1e2837;
  --muted: #6b7585;
  --brand: #e8730f;
  --brand-2: #f59324;
  --brand-dark: #b9560a;
  --tint: #fdecdb;
  --danger: #e11d48;
  --ok: #0f7a39;
  --shadow-sm: 0 1px 2px rgba(30,40,60,.06);
  --shadow-md: 0 6px 16px rgba(30,40,60,.09);
  --shadow-lg: 0 20px 44px rgba(90,60,30,.16);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Zen Kaku Gothic New", -apple-system, BlinkMacSystemFont, "Segoe UI", "Hiragino Sans",
    "Hiragino Kaku Gothic ProN", "Noto Sans JP", Meiryo, sans-serif;
  color: var(--text);
  background:
    radial-gradient(1200px 600px at 12% -8%, #ffe6cc 0%, transparent 55%),
    radial-gradient(1000px 560px at 100% 0%, #ffedd9 0%, transparent 50%),
    linear-gradient(180deg, #fbe9d8, #fef3e8);
  background-attachment: fixed;
  font-size: 14px;
  line-height: 1.65;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
/* 暖色グラデの上に、色を抜いたHANE背景を薄く重ねる（他ツールと共通） */
body::after {
  content: ""; position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background: url("/assets/hane-bg-gray.jpg") center center / cover no-repeat fixed;
  opacity: .12;
}
header, .toolbar, .landing, main { position: relative; z-index: 1; }
.hidden { display: none !important; }

/* ===== Header ===== */
header.app-header {
  background: rgba(255,255,255,.92);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
  padding: 13px 22px;
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  position: sticky; top: 0; z-index: 40;
}
.brand { display: inline-flex; align-items: center; gap: 9px; text-decoration: none; color: var(--text); }
.brand-logo { height: 30px; width: auto; display: block; }
.topnav { display: flex; gap: 6px; }
.topnav-btn {
  font-size: 13px; font-weight: 700; padding: 6px 11px; border-radius: 0;
  text-decoration: none; color: var(--brand-dark); border: 1px solid transparent;
}
.topnav-btn.link:hover { background: var(--tint); border-color: #f3d6b0; }
.topnav-btn.active { background: var(--brand); color: #fff; }
.app-header .spacer { flex: 1; }
.privacy-badge {
  font-size: 12px; color: var(--ok); font-weight: 600;
  background: #e7f9ef; border: 1px solid #b6ecc9; padding: 4px 11px; border-radius: 0; white-space: nowrap;
}
.counter {
  font-size: 13px; color: var(--brand-dark); font-weight: 700;
  background: var(--tint); border: 1px solid #f3d6b0; padding: 4px 11px; border-radius: 0; white-space: nowrap;
}
.counter.live { color: #fff; background: var(--ok); border-color: var(--ok); }
.counter.busy { color: #fff; background: var(--brand); border-color: var(--brand); }

/* ===== Buttons ===== */
.btn {
  font: inherit; font-weight: 700; cursor: pointer;
  padding: 8px 14px; border-radius: 0;
  border: 1px solid var(--border-strong); background: #fff; color: var(--text);
  box-shadow: var(--shadow-sm); transition: .12s;
}
.btn:hover { border-color: var(--brand-2); }
.btn.primary { background: var(--brand); color: #fff; border-color: var(--brand-dark); }
.btn.primary:hover { background: var(--brand-dark); }
.btn.big { font-size: 16px; padding: 13px 22px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

/* ===== Landing（接続前）: 他ツールと同じ hero + steps + features ===== */
.landing { padding: 30px 22px 44px; flex: 1 1 auto; }
.hero { max-width: 920px; margin: 26px auto 0; display: flex; flex-direction: column; align-items: center; gap: 22px; }
.hero-card {
  width: 100%; background: rgba(255,255,255,.66); border: 1px solid var(--border-strong);
  padding: 50px 28px 44px; text-align: center;
}
.hero-icon {
  width: 80px; height: 80px; margin: 0 auto 22px; font-size: 38px;
  display: flex; align-items: center; justify-content: center; color: var(--brand); background: var(--tint);
}
.hero h2 { font-size: 27px; margin: 0 0 12px; font-weight: 800; letter-spacing: .4px; color: var(--text); }
.hero-sub { color: #3f4654; margin: 0 0 24px; font-size: 15px; line-height: 1.7; }
.hero-sub strong { color: var(--brand); font-weight: 700; }
.hero-note { color: var(--muted); font-size: 12.5px; line-height: 1.6; margin: 18px 0 0; }
.hero-privacy { color: var(--ok); font-size: 12.5px; margin: 8px 0 0; font-weight: 600; }

.steps { display: flex; align-items: stretch; gap: 10px; flex-wrap: wrap; justify-content: center; width: 100%; }
.step { flex: 1; min-width: 170px; background: #fff; border: 1px solid var(--border); padding: 16px 18px; display: flex; align-items: center; gap: 14px; }
.step .num { flex: none; width: 30px; height: 30px; background: var(--brand); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 14px; }
.step div { display: flex; flex-direction: column; line-height: 1.45; }
.step b { font-size: 14px; }
.step div span { color: var(--muted); font-size: 12px; }
.step-arrow { display: flex; align-items: center; color: #e3b585; font-size: 18px; font-weight: 700; }

/* ===== できること（他ツール共通のフラットなセルgrid） ===== */
.features {
  width: 100%; display: grid; grid-template-columns: repeat(auto-fit, minmax(205px, 1fr));
  gap: 1px; background: var(--border); border: 1px solid var(--border);
}
.feat { background: #fff; padding: 18px 20px; display: flex; align-items: center; gap: 15px; transition: background .12s; }
.feat:hover { background: #fdf5ec; }
.feat .ico {
  flex: none; width: 40px; height: 40px; background: var(--tint); color: var(--brand);
  display: flex; align-items: center; justify-content: center; font-size: 19px;
}
.feat .txt { display: flex; flex-direction: column; gap: 2px; line-height: 1.4; }
.feat .txt b { font-size: 14px; font-weight: 700; }
.feat .txt small { color: var(--muted); font-size: 11.5px; }

/* ===== Toolbar ===== */
.toolbar {
  position: sticky; top: 60px; z-index: 30;
  background: rgba(255,255,255,.92); backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  padding: 11px 22px; display: flex; gap: 14px; flex-wrap: wrap; align-items: center;
}
.toolbar .group { display: inline-flex; align-items: center; gap: 8px; }
.toolbar .spacer { flex: 1; }
.group-label { font-size: 12px; color: var(--muted); font-weight: 700; }
.sel { font: inherit; padding: 6px 8px; border-radius: 0; border: 1px solid var(--border-strong); background: #fff; }
.chk { font-size: 13px; display: inline-flex; align-items: center; gap: 5px; cursor: pointer; user-select: none; }

/* ===== Stage / work ===== */
.stage-wrap { display: flex; gap: 18px; padding: 20px 22px; align-items: flex-start; flex-wrap: wrap; }
.stage {
  position: relative; flex: 1 1 560px; min-width: 320px;
  background: #0e1726; border: 1px solid var(--border-strong); border-radius: 0;
  overflow: hidden; box-shadow: var(--shadow-md); line-height: 0;
}
#video { width: 100%; display: block; }
.stage-tip {
  position: absolute; left: 0; right: 0; bottom: 0; line-height: 1.5;
  background: rgba(14,23,38,.82); color: #dce7f7; font-size: 12px; padding: 8px 12px;
}
.selbox {
  position: absolute; left: 8%; top: 35%; width: 38%; height: 16%;
  border: 2.5px solid #38bdf8; background: rgba(56,189,248,.14);
  box-shadow: 0 0 0 9999px rgba(8,14,24,.35); cursor: move; border-radius: 0;
}
.sel-label {
  position: absolute; top: -22px; left: 0; font-size: 11px; line-height: 1;
  background: #38bdf8; color: #06263a; font-weight: 800; padding: 4px 7px; border-radius: 0; white-space: nowrap;
}
.handle {
  position: absolute; width: 18px; height: 18px; background: #38bdf8;
  border: 2px solid #fff; border-radius: 0;
}
.handle.se { right: -10px; bottom: -10px; cursor: nwse-resize; }

/* ===== Result pane ===== */
.result-pane {
  flex: 0 0 320px; display: flex; flex-direction: column; gap: 16px;
}
.read-now { width: 100%; }
.latest-label { font-size: 12px; color: var(--muted); font-weight: 700; margin-bottom: 6px; }
.latest, .ocr-preview, .history {
  background: var(--panel); border: 1px solid var(--border); border-radius: 0;
  padding: 14px 16px; box-shadow: var(--shadow-sm);
}
.latest-value {
  font-size: 30px; font-weight: 800; letter-spacing: .04em; color: var(--brand-dark);
  word-break: break-all; min-height: 38px; font-variant-numeric: tabular-nums;
}
.latest-value.flash { animation: flash .6s ease; }
@keyframes flash { 0% { background: #fff7c2; } 100% { background: transparent; } }
.copy-again { margin-top: 10px; }
#cropCanvas { width: 100%; background: #f4f7fc; border: 1px solid var(--border); border-radius: 0; image-rendering: pixelated; }
.history ul { list-style: none; margin: 0; padding: 0; max-height: 240px; overflow: auto; }
.history li {
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  padding: 8px 6px; border-bottom: 1px dashed var(--border); cursor: pointer; font-size: 15px;
}
.history li:hover { background: var(--tint); }
.history li .num { font-weight: 700; letter-spacing: .03em; font-variant-numeric: tabular-nums; }
.history li .time { font-size: 11px; color: var(--muted); }
.history li.empty { color: var(--muted); cursor: default; font-size: 13px; }
.history li.empty:hover { background: none; }

/* ===== Toast ===== */
.toast {
  position: fixed; left: 50%; bottom: 30px; transform: translateX(-50%) translateY(20px);
  background: #0e1726; color: #fff; padding: 12px 22px; border-radius: 0;
  font-weight: 700; box-shadow: var(--shadow-lg); opacity: 0; pointer-events: none;
  transition: .22s; z-index: 90; max-width: 80vw;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.err { background: var(--danger); }
.toast.ok { background: var(--ok); }

@media (max-width: 860px) {
  .result-pane { flex: 1 1 100%; }
}

/* ===== スポイト（色取得） ===== */
.stage.pick, .stage.pick .selbox, .stage.pick .handle { cursor: crosshair; }
.colorpick {
  background: var(--panel); border: 1px solid var(--border);
  padding: 14px 16px; box-shadow: var(--shadow-sm);
}
.cp-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.cp-swatch { width: 34px; height: 34px; border: 1px solid var(--border-strong); flex: none; }
.btn.cc { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; letter-spacing: .02em; }

/* ===== ヘッダーのロゴ枠を固定幅に統一：ページ切替時のメニュー位置ズレ(がたがた)防止 ===== */
.app-header .brand { flex: 0 0 132px; width: 132px; justify-content: flex-start; }
.app-header .brand-logo { height: 30px; width: auto; max-width: 100%; display: block; }

/* ===== ヘッダー：ナビは折り返して全項目表示。ログインは右上固定(gate.jsが絶対配置) ===== */
.app-header .privacy-badge{ white-space:nowrap; }

/* ===== 全ツール共通：メニューバー・ボタンの高さ統一 ===== */
header.app-header{ min-height:56px; padding-top:0; padding-bottom:0; align-items:center; gap:12px; }
.app-header .topnav{ align-items:center; gap:6px; }
.app-header .topnav-btn{ box-sizing:border-box; height:32px; line-height:1; padding:0 11px; display:inline-flex; align-items:center; border:1px solid transparent; border-radius:0; font-size:13px; font-weight:700; }
.app-header .topnav-btn.active{ border-color:#4f46e5; }

/* ===== スマホ対応：注意書きを隠し、ナビは横スクロール ===== */
@media (max-width:640px){
  header.app-header{ flex-wrap:wrap; min-height:auto; padding:8px 12px; gap:8px 10px; }
  .app-header .brand{ flex:0 0 auto; width:auto; }
  .app-header .privacy-badge{ display:none; }
  .app-header .topnav{ flex:1 1 100%; order:5; flex-wrap:nowrap; overflow-x:auto; -webkit-overflow-scrolling:touch; gap:6px; }
  .app-header .topnav::-webkit-scrollbar{ height:0; }
}
