/* Elements and shared controls. */

*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: var(--fs-m)/1.55 var(--body);
  -webkit-text-size-adjust: 100%;
}

h1, h2, h3, p { margin: 0; }
h2 { font-size: var(--fs-l); line-height: 1.4; }
h3 { font-size: var(--fs-m); }
a { color: var(--blue-ink); }
[hidden] { display: none !important; }

:focus-visible { outline: 2px solid var(--blue-ink); outline-offset: 2px; }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}

/* ---------------------------------------------------------------- buttons */

button, input, select, textarea { font: inherit; color: inherit; }
button, a, input, select, textarea, summary { -webkit-tap-highlight-color: transparent; }
button, select { touch-action: manipulation; }

button {
  cursor: pointer;
  min-height: 40px;
  padding: 8px 14px;
  background: var(--sheet);
  border: 1px solid var(--rule);
  border-radius: var(--r-m);
  font-weight: 600;
  line-height: 1.35;
}
button:hover { background: var(--hover); border-color: var(--field-line); }
button:disabled { cursor: default; opacity: .4; }
button:disabled:hover { background: var(--sheet); border-color: var(--rule); }

button.primary { background: var(--blue-ink); border-color: var(--blue-ink); color: #fff; }
button.primary:hover { background: var(--blue-ink-hover); border-color: var(--blue-ink-hover); }

button.quiet { background: transparent; border-color: transparent; color: var(--blue-ink); padding-inline: 8px; }
button.quiet:hover { background: var(--hover); }
button.quiet:disabled:hover { background: transparent; border-color: transparent; }

button.danger { background: var(--danger); border-color: var(--danger); color: #fff; }

.subtle-danger {
  min-height: 32px; padding: 4px 0;
  border: 0; background: transparent;
  color: var(--danger); font-size: var(--fs-s); text-align: left;
}
.subtle-danger:hover { background: transparent; text-decoration: underline; }
.subtle-danger:disabled:hover { background: transparent; text-decoration: none; }

.icon-btn { min-width: 44px; padding: 0; font-size: 22px; font-weight: 400; }

/* ---------------------------------------------------------------- fields */

input, select, textarea {
  width: 100%;
  min-width: 0;
  min-height: 42px;
  padding: 9px 10px;
  background: var(--sheet);
  border: 1px solid var(--field-line);
  border-radius: 6px;
}
input:hover, select:hover, textarea:hover { border-color: var(--ink-soft); }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline-offset: 0; border-color: var(--blue-ink); }
input[type=color] { padding: 4px; cursor: pointer; }
input:invalid:not(:focus) { border-color: var(--danger); }
textarea { resize: vertical; line-height: 1.65; }

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; font-size: var(--fs-s); font-weight: 600; color: var(--ink-soft); }
.field > input, .field > select, .field > textarea { font-size: var(--fs-m); font-weight: 400; color: var(--ink); }
.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; align-items: end; }
.field-row { display: flex; gap: 12px; align-items: end; }
.field-row > .field { flex: 1; }
.inline { display: flex; gap: 6px; }
.note { font-size: var(--fs-s); font-weight: 400; color: var(--muted); line-height: 1.7; }

.check { display: inline-flex; align-items: center; gap: 6px; font-size: var(--fs-s); }
.check input { width: 16px; min-height: 16px; }

/* ---------------------------------------------------------------- disclosure */

summary {
  cursor: pointer;
  list-style: none;
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  min-height: 32px;
  font-weight: 700;
}
summary::-webkit-details-marker { display: none; }
summary::after { content: '＋'; font-weight: 400; color: var(--muted); }
details[open] > summary::after { content: '−'; }

/* ---------------------------------------------------------------- scripts */

html:lang(ja), html:lang(zh-Hans), html:lang(zh-Hant), html:lang(zh-HK), html:lang(ko) { line-break: strict; }
html:lang(ko) .note, html:lang(ko) .field { word-break: keep-all; }
html:lang(th) .field, html:lang(th) .note { line-height: 1.8; }
html:lang(th) button { line-height: 1.6; }

@media (prefers-reduced-motion: no-preference) {
  button, input, select { transition: background-color 120ms, border-color 120ms, color 120ms; }
}
