/* ─── Variables ─────────────────────────────────────────────────────────────── */
:root {
  --bg:         #f5f5f5;
  --surface:    #ffffff;
  --surface2:   #f0f0f0;
  --border:     #d0d0d0;
  --text:       #1a1a1a;
  --text-muted: #666666;
  --accent:     #2563eb;
  --accent-h:   #1d4ed8;
  --btn-bg:     #e8e8e8;
  --btn-hover:  #d8d8d8;
  --radius:     8px;
  --shadow:     0 1px 4px rgba(0,0,0,.08);
}

[data-theme="dark"] {
  --bg:         #0f0f0f;
  --surface:    #1a1a1a;
  --surface2:   #252525;
  --border:     #333333;
  --text:       #e8e8e8;
  --text-muted: #888888;
  --accent:     #3b82f6;
  --accent-h:   #60a5fa;
  --btn-bg:     #2a2a2a;
  --btn-hover:  #383838;
  --shadow:     0 1px 4px rgba(0,0,0,.4);
}

/* ─── Reset ─────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Helvetica Neue',
               'Noto Sans JP', 'Hiragino Kaku Gothic Pro', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-size: 15px;
  line-height: 1.5;
}

/* ─── Header ─────────────────────────────────────────────────────────────────── */
.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow);
  position: sticky;
  top: 0;
  z-index: 10;
}

.header-inner {
  max-width: 960px;
  margin: 0 auto;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

h1 {
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
}

.subtitle {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 1px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.icon-btn {
  background: var(--btn-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 6px 10px;
  cursor: pointer;
  font-size: 1rem;
  color: var(--text);
  transition: background .15s;
}
.icon-btn:hover { background: var(--btn-hover); }

.lang-btn {
  background: var(--btn-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 5px 12px;
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text);
  letter-spacing: .05em;
  transition: background .15s;
}
.lang-btn:hover { background: var(--btn-hover); }

/* ─── Main ───────────────────────────────────────────────────────────────────── */
.main {
  flex: 1;
  max-width: 960px;
  margin: 0 auto;
  width: 100%;
  padding: 24px 20px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* ─── Controls ───────────────────────────────────────────────────────────────── */
.controls-bar {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
  align-items: flex-end;
}

.control-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.control-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .04em;
}

.select {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 7px 32px 7px 10px;
  font-size: 0.9rem;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23666' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  min-width: 200px;
  transition: border-color .15s, box-shadow .15s;
}
.select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 20%, transparent);
}

/* ─── Converter ──────────────────────────────────────────────────────────────── */
.converter {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 16px;
  align-items: start;
}

.pane {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.pane-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.pane-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .04em;
}

.pane-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.char-count {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.textarea {
  width: 100%;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  font-size: 1rem;
  font-family: inherit;
  resize: vertical;
  min-height: 180px;
  line-height: 1.6;
  transition: border-color .15s, box-shadow .15s;
}
.textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 20%, transparent);
}
.output-textarea {
  background: var(--surface2);
  cursor: default;
  color: var(--text);
}

/* ─── Action column ──────────────────────────────────────────────────────────── */
.action-col {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-top: 26px;
}

.action-btn {
  background: var(--btn-bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 14px;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s;
}
.action-btn:hover { background: var(--btn-hover); }
.swap-btn {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.swap-btn:hover { background: var(--accent-h); border-color: var(--accent-h); }

.copy-btn {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  padding: 4px 12px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s;
}
.copy-btn:hover { background: var(--accent-h); }

/* ─── Reference table ────────────────────────────────────────────────────────── */
.reference {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.reference details > summary {
  padding: 12px 16px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  color: var(--text-muted);
  list-style: none;
  display: flex;
  align-items: center;
  gap: 6px;
}
.reference details > summary::before {
  content: '▶';
  font-size: 0.65rem;
  transition: transform .2s;
}
.reference details[open] > summary::before { transform: rotate(90deg); }

.ref-table-wrap {
  overflow-x: auto;
  padding: 0 16px 16px;
}

.ref-table {
  border-collapse: collapse;
  font-size: 0.85rem;
  min-width: 300px;
}
.ref-table th, .ref-table td {
  padding: 6px 16px 6px 0;
  text-align: left;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}
.ref-table th {
  font-weight: 600;
  color: var(--text-muted);
  font-size: 0.78rem;
}
.ref-table td:first-child {
  font-size: 1rem;
}

/* ─── Footer ─────────────────────────────────────────────────────────────────── */
.site-footer {
  background: var(--surface);
  border-top: 1px solid var(--border);
  text-align: center;
  padding: 14px 20px;
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* ─── Responsive ─────────────────────────────────────────────────────────────── */
@media (max-width: 680px) {
  .converter {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto;
  }
  .action-col {
    flex-direction: row;
    padding-top: 0;
    justify-content: center;
  }
  .controls-bar {
    gap: 14px;
  }
  .select { min-width: 160px; }
  h1 { font-size: 1.2rem; }
}
