/* ビルダー編集画面(index.html)専用スタイル。
   画面テーマ: 既定は「白(わんコメ風)」。html[data-theme="booth"] / [data-theme="fanbox"] で
   トークンを差し替える。テーマはビルダー画面専用で、/clock/ には適用されない。 */

:root {
  --page-bg: #ffffff;
  --ink: #222222;
  --muted: #6b6b6b;
  --line: #e4e4e4;
  --line-strong: #cfcfcf;
  --panel: #ffffff;
  --panel-strong: #ffffff;
  --accent: #bc5509;
  --accent-hover: #9c4708;
  --accent-ink: #ffffff;
  --accent-soft: #fdeee6;
  --accent-bright: #f57c1f;
  --warm: #b3520a;
  --warm-soft: #fdf3ea;
  --panel-radius: 10px;
  --button-radius: 8px;
  --shadow: 0 2px 10px rgba(40, 36, 32, 0.05);
  --shadow-soft: 0 1px 6px rgba(40, 36, 32, 0.05);
}

:root[data-theme="booth"] {
  --accent: #d83538;
  --accent-hover: #b22b2e;
  --accent-soft: #feeced;
  --accent-bright: #fc4d50;
  --warm: #d83538;
  --warm-soft: #fdf1f1;
  --line: #e5e5e4;
  --line-strong: #d2d2d0;
  --button-radius: 6px;
}

:root[data-theme="fanbox"] {
  --page-bg: linear-gradient(120deg, #e9f6c8 0%, #d9f0e3 45%, #cfeaf8 100%);
  --ink: #1f2d33;
  --muted: #5d6b73;
  --line: #e3eaee;
  --line-strong: #c9d6dd;
  --accent: #0075c4;
  --accent-hover: #005d9e;
  --accent-soft: #e3f3fd;
  --accent-bright: #0096fa;
  --warm: #0075c4;
  --warm-soft: #ecf6fd;
  --panel-radius: 16px;
  --button-radius: 999px;
  --shadow: 0 4px 16px rgba(70, 90, 100, 0.12);
  --shadow-soft: 0 2px 10px rgba(70, 90, 100, 0.1);
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
.button-like {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 16px;
  border: 1px solid transparent;
  border-radius: var(--button-radius);
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 0.94rem;
  font-weight: 800;
  line-height: 1.2;
  text-decoration: none;
  cursor: pointer;
  transition: transform 120ms ease, box-shadow 120ms ease, background 120ms ease, border-color 120ms ease;
}

button:hover,
.button-like:hover {
  background: var(--accent-hover);
  box-shadow: 0 6px 14px rgba(34, 30, 26, 0.16);
  transform: translateY(-1px);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.56;
  transform: none;
}

button:focus-visible,
.button-like:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
summary:focus-visible,
a:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

button.secondary,
.button-like.secondary {
  background: #ffffff;
  color: var(--accent);
  border-color: var(--accent-bright);
}

button.secondary:hover,
.button-like.secondary:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
  box-shadow: var(--shadow-soft);
}

.skip-link {
  position: fixed;
  top: 10px;
  left: 10px;
  z-index: 20;
  padding: 10px 14px;
  border-radius: 8px;
  background: #ffffff;
  color: var(--accent);
  font-weight: 800;
  text-decoration: none;
  transform: translateY(-140%);
}

.skip-link:focus {
  transform: translateY(0);
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  width: min(var(--content-width), calc(100% - 32px));
  margin: 0 auto;
  padding: 24px 0 16px;
}

.topbar-copy {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.topbar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
  padding-top: 4px;
}

.eyebrow {
  margin: 0;
  color: var(--warm);
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 2.45rem;
  line-height: 1.15;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 5px;
  font-size: 1.08rem;
  line-height: 1.35;
}

h3 {
  margin: 0 0 12px;
  font-size: 0.96rem;
  line-height: 1.4;
}

code {
  padding: 1px 4px;
  border-radius: 4px;
  background: rgba(34, 30, 26, 0.07);
  color: #45403a;
  font-family: "Roboto Mono", Consolas, monospace;
  font-size: 0.92em;
}

.lead {
  max-width: 720px;
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.75;
}

.quiet-link {
  color: var(--accent);
  font-weight: 800;
  text-decoration: none;
}

.quiet-link:hover {
  text-decoration: underline;
}

.builder-layout {
  display: grid;
  grid-template-columns: minmax(340px, 420px) minmax(0, 1fr);
  grid-template-areas: "preview controls";
  gap: 18px;
  width: min(var(--content-width), calc(100% - 32px));
  margin: 0 auto 48px;
  align-items: start;
}

.builder-layout:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 4px;
}

.control-surface {
  grid-area: controls;
  display: grid;
  gap: 14px;
  min-width: 0;
}

.preview-column {
  grid-area: preview;
  position: sticky;
  top: 16px;
  display: grid;
  gap: 14px;
  min-width: 0;
}

.panel,
.preview-panel {
  border: 1px solid var(--line);
  border-radius: var(--panel-radius);
  background: var(--panel);
  box-shadow: var(--shadow);
  padding: 18px;
}

:root[data-theme="fanbox"] .panel,
:root[data-theme="fanbox"] .preview-panel {
  border-color: transparent;
}

.preview-panel {
  background: var(--panel-strong);
  max-width: 100%;
  min-width: 0;
}

.preview-primary {
  border-color: var(--line-strong);
}

.url-panel {
  border-color: var(--line-strong);
  background: var(--panel-strong);
}

.section-heading {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-bottom: 14px;
}

.section-heading p,
small,
.muted {
  color: var(--muted);
  line-height: 1.6;
}

.info-note {
  margin: 0 0 14px;
  padding: 11px 12px;
  border: 1px solid #efd2ac;
  border-left: 4px solid var(--warm);
  border-radius: 8px;
  background: var(--warm-soft);
  color: #3d3027;
  line-height: 1.65;
}

.info-note strong {
  display: block;
  margin-bottom: 2px;
  font-size: 0.92rem;
}

.info-note p,
.copy-hint {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.65;
}

.copy-hint {
  margin-top: 8px;
}

.template-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
}

.template-button {
  display: grid;
  min-height: 96px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
  text-align: left;
  box-shadow: none;
}

.template-button:hover {
  background: #fafafa;
  border-color: var(--accent-bright);
  box-shadow: var(--shadow-soft);
}

.template-button[aria-pressed="true"] {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.template-name {
  margin-top: 9px;
  font-weight: 800;
}

.template-note {
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.35;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.dense-grid {
  grid-template-columns: repeat(auto-fit, minmax(178px, 1fr));
}

.design-groups {
  display: grid;
  gap: 14px;
}

.control-group {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fafafa;
}

:root[data-theme="fanbox"] .control-group {
  background: #f6fafc;
}

.field {
  display: grid;
  gap: 7px;
  min-width: 0;
}

.field > span,
.toggle span,
.inline-actions > span {
  font-weight: 800;
  font-size: 0.92rem;
}

input[type="text"],
input[type="color"],
input[type="range"],
select,
textarea {
  width: 100%;
}

input[type="text"],
select,
textarea {
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
}

input[type="text"],
select {
  min-height: 44px;
  padding: 0 12px;
}

textarea {
  resize: vertical;
  min-height: 88px;
  padding: 10px 12px;
  line-height: 1.55;
}

.url-field {
  margin-top: 12px;
}

#generatedUrl {
  min-height: 130px;
  font-size: 0.88rem;
}

input[type="color"] {
  height: 44px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #ffffff;
  padding: 4px;
}

input[type="range"] {
  accent-color: var(--accent-bright);
}

output {
  color: var(--muted);
  font-size: 0.86rem;
}

.toggle {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 44px;
}

.toggle input {
  width: 19px;
  height: 19px;
  accent-color: var(--accent-bright);
}

.inline-actions {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px 12px;
}

.inline-actions span,
.inline-actions p {
  grid-column: 1 / -1;
  margin: 0;
}

.swatches {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.swatch {
  width: 40px;
  height: 40px;
  min-height: 40px;
  padding: 0;
  border: 1px solid rgba(0, 0, 0, 0.18);
  border-radius: 50%;
  box-shadow: none;
}

.swatch:hover {
  box-shadow: none;
  transform: scale(1.04);
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-top: 12px;
}

.primary-actions button:first-child {
  flex: 1 1 180px;
}

.preview-actions {
  margin: 0 0 8px;
}

.status-line {
  min-height: 1.4em;
  margin: 10px 0 0;
  color: #2f6a3c;
  font-size: 0.9rem;
}

/* 調整タブ直下の常時表示ステータス。空でも高さを確保して切替時のガタつきを防ぐ。 */
.builder-status {
  margin: 6px 0 12px;
}

.preview-status {
  margin: 0 0 10px;
}

.warning {
  margin: 12px 0 0;
  padding: 10px 12px;
  border: 1px solid #e5b769;
  border-radius: 8px;
  background: #fff7e8;
  color: #62400d;
  line-height: 1.6;
}

.preview-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  align-items: center;
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 0.9rem;
}

.preview-toolbar label {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 44px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: #25302c;
  cursor: pointer;
  line-height: 1.2;
}

.preview-toolbar label:hover {
  border-color: var(--accent-bright);
  background: var(--accent-soft);
}

.preview-toolbar label:focus-within {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
  border-color: var(--focus);
}

.preview-toolbar input[type="radio"] {
  flex: 0 0 auto;
  width: 19px;
  height: 19px;
  accent-color: var(--accent-bright);
}

.preview-toolbar input[type="color"] {
  box-sizing: border-box;
  width: 44px;
  height: 34px;
  min-height: 44px;
  padding: 3px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  cursor: pointer;
}

.preview-shell {
  position: relative;
  display: grid;
  place-items: center;
  box-sizing: border-box;
  max-width: 100%;
  min-width: 0;
  min-height: 250px;
  padding: 24px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  overflow: hidden;
}

.preview-checker {
  background:
    linear-gradient(45deg, #d7d7d7 25%, transparent 25%),
    linear-gradient(-45deg, #d7d7d7 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #d7d7d7 75%),
    linear-gradient(-45deg, transparent 75%, #d7d7d7 75%);
  background-color: #f5f5f5;
  background-position: 0 0, 0 10px, 10px -10px, -10px 0;
  background-size: 20px 20px;
}

.preview-light {
  background: #fffdf5;
}

.preview-dark {
  background: #161821;
}

.preview-custom {
  background: var(--preview-custom, #5f7fbe);
}

.preview-stage {
  display: flex;
  align-items: safe center;
  justify-content: safe center;
  box-sizing: border-box;
  inline-size: 100%;
  max-width: 100%;
  min-width: 0;
  padding: var(--clock-visual-safe-inset, 18px);
  overflow: auto;
  overscroll-behavior: contain;
}

.preview-stage .clock-widget {
  flex: 0 0 auto;
  max-width: none;
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.metrics-grid div {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.metrics-grid span {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 0.82rem;
}

.metrics-grid strong {
  font-size: 1.1rem;
}

.help-steps {
  margin: 14px 0 0;
  padding-left: 1.35rem;
  line-height: 1.8;
}

.faq-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 16px;
}

details {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  padding: 10px 12px;
}

summary {
  cursor: pointer;
  font-weight: 800;
}

details p {
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.7;
}

.is-hidden {
  display: none !important;
}

@media (max-width: 1100px) {
  .builder-layout {
    grid-template-columns: 1fr;
    grid-template-areas:
      "preview"
      "controls";
  }

  .preview-column {
    position: static;
  }
}

@media (max-width: 820px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  h1 {
    font-size: 2rem;
  }

  .form-grid,
  .faq-grid {
    grid-template-columns: 1fr;
  }

  .panel,
  .preview-panel {
    padding: 14px;
  }

  .preview-shell {
    min-height: 210px;
    padding: 18px;
  }
}

@media (max-width: 520px) {
  .topbar,
  .builder-layout {
    width: calc(100% - 20px);
  }

  .topbar {
    padding-top: 18px;
  }

  h1 {
    font-size: 1.78rem;
  }

  .template-grid {
    grid-template-columns: 1fr;
  }

  .button-row,
  .primary-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .button-row > *,
  .primary-actions > * {
    flex: 0 0 auto;
    width: 100%;
  }

  .primary-actions button:first-child {
    flex: 0 0 auto;
  }
}

@media (pointer: coarse) {
  button,
  .button-like,
  input[type="text"],
  select,
  .toggle {
    min-height: 48px;
  }

  .swatch {
    width: 44px;
    height: 44px;
    min-height: 44px;
  }
}

.theme-picker {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 700;
}

.theme-picker select {
  width: auto;
  min-height: 44px;
  padding: 0 10px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
}

.topbar-actions .quiet-link {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 14px;
  border: 1px solid var(--accent-bright);
  border-radius: var(--button-radius);
  background: #ffffff;
}

.step-heading {
  flex-direction: row;
  align-items: flex-start;
  gap: 12px;
}

.step-heading > div {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.step-badge {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  margin-top: 1px;
  border-radius: 8px;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 1rem;
  font-weight: 800;
}

:root[data-theme="booth"] .step-badge,
:root[data-theme="fanbox"] .step-badge {
  border-radius: 50%;
}

.clock-type-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.clock-type-row > span {
  margin-right: 4px;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 700;
}

.analog-controls {
  margin-top: 12px;
}

.template-mini-analog {
  display: flex;
  align-items: center;
  justify-content: center;
}

.template-mini-analog svg {
  width: 64px;
  height: 64px;
}

.template-mini-flip {
  display: flex;
  align-items: center;
  justify-content: center;
  max-width: 100%;
}

.template-mini-flip .clock-flip {
  transform: scale(0.92);
}

.adjust-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

button.adjust-tab {
  min-width: 112px;
  background: #ffffff;
  color: var(--muted);
  border-color: var(--line-strong);
}

button.adjust-tab:hover {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: var(--accent-bright);
}

button.adjust-tab[aria-pressed="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}

button.adjust-tab[aria-pressed="true"]:hover {
  background: var(--accent-hover);
}

.toggle-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 20px;
  margin-top: 12px;
}

.group-hint {
  margin: -4px 0 12px;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.6;
}

.category-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

button.category-tab {
  min-height: 44px;
  padding: 0 16px;
  background: #ffffff;
  color: var(--muted);
  border-color: var(--line-strong);
  border-radius: 999px;
  font-size: 0.88rem;
}

button.category-tab:hover {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: var(--accent-bright);
}

button.category-tab[aria-pressed="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}

button.category-tab[aria-pressed="true"]:hover {
  background: var(--accent-hover);
}

.template-mini {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 76px;
  overflow: hidden;
  border-radius: 8px;
  background:
    linear-gradient(45deg, #e3e3e3 25%, transparent 25%),
    linear-gradient(-45deg, #e3e3e3 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #e3e3e3 75%),
    linear-gradient(-45deg, transparent 75%, #e3e3e3 75%);
  background-color: #f4f4f4;
  background-position: 0 0, 0 6px, 6px -6px, -6px 0;
  background-size: 12px 12px;
}

.template-mini-clock {
  flex: 0 0 auto;
  max-width: none;
  transform: scale(0.42);
  transform-origin: center;
  pointer-events: none;
  white-space: nowrap;
}
