/* 額縁シミュレーター */
* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }

:root {
  --ink: #2b2a28;
  --muted: #8a857d;
  --line: #e3ded6;
  --bg: #faf8f5;
  --panel: #ffffff;
  --accent: #7a5c3a;
}

body {
  font-family: "Hiragino Kaku Gothic ProN", "Hiragino Sans", system-ui, sans-serif;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.6;
}

header {
  display: flex;
  align-items: baseline;
  gap: 16px;
  padding: 18px 28px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}
header h1 { font-size: 19px; font-weight: 600; letter-spacing: 0.06em; }
header .brand { font-size: 12.5px; color: var(--muted); letter-spacing: 0.08em; }

main {
  display: grid;
  grid-template-columns: 270px 1fr 290px;
  gap: 20px;
  padding: 20px 28px;
  max-width: 1400px;
  margin: 0 auto;
}

/* --- 左：コントロール --- */
.controls section { margin-bottom: 22px; }
.controls h2 {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.1em;
  margin-bottom: 8px;
}
.radio-row { display: flex; flex-direction: column; gap: 4px; }
.radio-row label, .check { font-size: 14px; display: flex; align-items: center; gap: 7px; cursor: pointer; }
.size-row { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.size-row label { display: flex; flex-direction: column; gap: 2px; }
input[type="number"] {
  width: 90px;
  padding: 6px 8px;
  font-size: 15px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
}
input[type="number"]:disabled {
  color: #b5b0a8;
  background: #f2efe9;
  border-color: #eae6df;
}
input[type="text"] {
  width: 100%;
  padding: 6px 8px;
  font-size: 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  margin-bottom: 8px;
}
.link-btn {
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  padding: 5px 8px;
  font-size: 14px;
  align-self: flex-end;
}
.link-btn.off { opacity: 0.35; }
.canvas.dragover { outline: 2px dashed var(--accent); outline-offset: -8px; }
input[type="file"] { font-size: 12.5px; margin-bottom: 6px; width: 100%; }
#mat-options { margin-top: 10px; display: flex; flex-direction: column; gap: 8px; }
#mat-options > label { font-size: 13px; display: flex; flex-direction: column; gap: 2px; }
.hint { font-size: 11.5px; color: var(--muted); margin-top: 4px; }
.notice { background: #f7efe2; border: 1px solid #e2cfa8; border-radius: 6px; padding: 6px 9px; color: #7a5c3a; font-size: 11.5px; margin-top: 4px; }
.sub-label { font-size: 12px; color: var(--muted); margin: 8px 0 3px; }
.warn { color: #a33d2e; }
.errors {
  background: #fbeeec;
  border: 1px solid #e5b8b1;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 12.5px;
  color: #a33d2e;
}

button {
  padding: 8px 14px;
  font-size: 13px;
  border: none;
  border-radius: 7px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
}
button:hover { opacity: 0.88; }
button.sub {
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--accent);
}
.size-presets { margin-bottom: 8px; }
.size-preset { padding: 4px 10px; font-size: 12px; }

/* --- 中央：プレビュー --- */
.preview { min-width: 0; }
.tabs { display: flex; gap: 6px; margin-bottom: 10px; }
.tab {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 7px 7px 0 0;
}
.tab.active { background: var(--panel); color: var(--ink); border-bottom-color: var(--panel); font-weight: 600; }
.canvas {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 0 10px 10px 10px;
  padding: 18px;
  min-height: 520px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.canvas[hidden] { display: none; }
.canvas svg { width: 100%; height: auto; max-height: 640px; display: block; }
.canvas-3d { flex-direction: column; align-items: stretch; gap: 8px; }
#view-3d { flex: 1; min-height: 480px; border-radius: 8px; overflow: hidden; }
#view-3d canvas { display: block; }
.preset-row { display: flex; gap: 6px; }
.preset {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--line);
  padding: 5px 12px;
  font-size: 12.5px;
}
.preset:hover { color: var(--ink); }

.dim-toggles {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 8px;
  font-size: 12px;
  color: var(--muted);
}
.dim-toggle {
  padding: 4px 12px;
  font-size: 12px;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--line);
}
.dim-toggle.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.dim-toggle:disabled {
  opacity: 0.4;
  cursor: default;
}
.dim-toggle:hover:not(:disabled) { opacity: 0.85; }
.dim-toggle.active:hover { opacity: 0.88; }

/* --- 右：情報 --- */
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px 16px;
  margin-bottom: 14px;
}
.card h2 {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.1em;
  margin-bottom: 8px;
}
.card table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.card th {
  text-align: left;
  font-weight: 500;
  color: var(--muted);
  padding: 4px 0;
  white-space: nowrap;
}
.card td { text-align: right; padding: 4px 0; font-variant-numeric: tabular-nums; }
.card td.unit { color: var(--muted); font-size: 11px; width: 26px; text-align: left; padding-left: 6px; }
.price { font-size: 24px; font-weight: 600; letter-spacing: 0.02em; }
.price .tax { font-size: 12px; color: var(--muted); font-weight: 400; }
#spec-text {
  font-family: inherit;
  font-size: 11.5px;
  color: var(--muted);
  background: var(--bg);
  border-radius: 6px;
  padding: 8px 10px;
  white-space: pre-wrap;
  word-break: break-all;
  margin-bottom: 10px;
  max-height: 150px;
  overflow-y: auto;
}
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }

footer {
  text-align: center;
  padding: 18px;
  font-size: 11.5px;
  color: var(--muted);
  letter-spacing: 0.08em;
}

/* --- レスポンシブ --- */
@media (max-width: 980px) {
  /* タイトル「額縁シミュレーター」が途中で折り返さないようヘッダーを縦積みにする */
  header { flex-direction: column; align-items: flex-start; gap: 2px; padding: 14px 16px 10px; }
  header h1 { font-size: 17px; white-space: nowrap; }
  main { grid-template-columns: 1fr; padding: 14px 14px; gap: 14px; }
  /* プレビューを画面上部に固定し、下の入力欄だけスクロールできるようにする（3Dタブも同じ固定枠に収める） */
  .preview { order: -1; position: sticky; top: 0; z-index: 20; background: var(--bg); padding-bottom: 6px; border-bottom: 1px solid var(--line); }
  .canvas { height: 35vh; min-height: 0; padding: 8px; }
  .canvas svg { width: 100%; height: 100%; max-height: none; }
  .canvas-3d { height: 35vh; }
  #view-3d { min-height: 0; }
  .canvas-3d .hint { display: none; }
  .dim-toggles { margin-top: 4px; }
  input[type="number"], input[type="text"] { font-size: 16px; } /* iOS Safariのフォーカス時自動ズーム防止（16px未満だとズームされる） */
}
