/* ========================================
   easy-split — Theme & Mobile-First CSS
   ======================================== */

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

/* ---- Theme: Dark (default) ---- */
[data-theme="dark"] {
  --bg-primary: #1a1a2e;
  --bg-secondary: #16213e;
  --bg-card: #0f3460;
  --text-primary: #e0e0e0;
  --text-secondary: #a0a0b0;
  --accent: #e94560;
  --accent-hover: #ff6b81;
  --border: #2a2a4a;
  --input-bg: #1a1a3e;
  --input-border: #3a3a5a;
  --btn-bg: #e94560;
  --btn-text: #fff;
  --shadow: rgba(0, 0, 0, 0.4);
  --slider-track: #3a3a5a;
  --slider-thumb: #e94560;
  --toggle-bg: #3a3a5a;
  --toggle-active: #e94560;
  --result-bg: #1a3a5e;
  --footer-bg: #0d1b2a;
}

/* ---- Theme: Simple ---- */
[data-theme="simple"] {
  --bg-primary: #f5f5f5;
  --bg-secondary: #ffffff;
  --bg-card: #ffffff;
  --text-primary: #333333;
  --text-secondary: #666666;
  --accent: #4a90d9;
  --accent-hover: #357abd;
  --border: #e0e0e0;
  --input-bg: #ffffff;
  --input-border: #cccccc;
  --btn-bg: #4a90d9;
  --btn-text: #ffffff;
  --shadow: rgba(0, 0, 0, 0.1);
  --slider-track: #cccccc;
  --slider-thumb: #4a90d9;
  --toggle-bg: #cccccc;
  --toggle-active: #4a90d9;
  --result-bg: #e8f4fd;
  --footer-bg: #e0e0e0;
}

/* ---- Theme: Metal ---- */
[data-theme="metal"] {
  --bg-primary: #1a1a1a;
  --bg-secondary: #2a2a2a;
  --bg-card: #333333;
  --text-primary: #d0d0d0;
  --text-secondary: #999999;
  --accent: #cc0000;
  --accent-hover: #ff2222;
  --border: #444444;
  --input-bg: #2a2a2a;
  --input-border: #555555;
  --btn-bg: #cc0000;
  --btn-text: #ffffff;
  --shadow: rgba(0, 0, 0, 0.6);
  --slider-track: #555555;
  --slider-thumb: #cc0000;
  --toggle-bg: #555555;
  --toggle-active: #cc0000;
  --result-bg: #2a1a1a;
  --footer-bg: #111111;
}

/* Metal texture overlay */
[data-theme="metal"] .card {
  background-image:
    linear-gradient(135deg, rgba(255,255,255,0.03) 25%, transparent 25%),
    linear-gradient(225deg, rgba(255,255,255,0.03) 25%, transparent 25%),
    linear-gradient(315deg, rgba(255,255,255,0.03) 25%, transparent 25%),
    linear-gradient(45deg, rgba(255,255,255,0.03) 25%, transparent 25%);
  background-size: 4px 4px;
  border: 1px solid #555;
}

/* ---- Base ---- */
html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Hiragino Sans',
    'Noto Sans JP', sans-serif;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ---- Header ---- */
.app-header {
  text-align: center;
  padding: 20px 16px 12px;
  background-color: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
}

.app-title {
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 0.05em;
}

.app-subtitle {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-top: 2px;
}

.theme-switcher {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-top: 10px;
}

.theme-btn {
  width: 44px;
  height: 44px;
  border: 2px solid var(--border);
  border-radius: 10px;
  background: var(--bg-card);
  font-size: 1.2rem;
  cursor: pointer;
  transition: border-color 0.2s, transform 0.1s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.theme-btn:active {
  transform: scale(0.95);
}

.theme-btn.active {
  border-color: var(--accent);
  box-shadow: 0 0 8px var(--accent);
}

/* ---- Container ---- */
.container {
  flex: 1;
  max-width: 480px;
  width: 100%;
  margin: 0 auto;
  padding: 12px 16px 24px;
}

/* ---- Card ---- */
.card {
  background-color: var(--bg-card);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: 0 2px 8px var(--shadow);
}

.card a {
  color: var(--accent);
}

.card h2 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 12px;
  color: var(--text-primary);
}

/* ---- Inputs ---- */
.amount-input-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.amount-input-group.sub {
  margin-top: 10px;
  font-size: 0.85rem;
}

.amount-input-group.sub label {
  white-space: nowrap;
  color: var(--text-secondary);
  min-width: 100px;
}

.amount-input-group input[type="number"] {
  flex: 1;
  min-width: 0;
  height: 48px;
  border: 1px solid var(--input-border);
  border-radius: 8px;
  background: var(--input-bg);
  color: var(--text-primary);
  font-size: 1.2rem;
  padding: 0 12px;
  text-align: right;
}

.amount-input-group.sub input[type="number"] {
  height: 40px;
  font-size: 1rem;
}

.currency {
  font-size: 1rem;
  color: var(--text-secondary);
  min-width: 20px;
}

input[type="number"]:focus,
select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(233, 69, 96, 0.2);
}

/* Remove spinner for number inputs */
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
input[type="number"] {
  -moz-appearance: textfield;
}

/* ---- Participant Row ---- */
.participant-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.participant-name {
  flex: 1;
  min-width: 80px;
  height: 44px;
  border: 1px solid var(--input-border);
  border-radius: 8px;
  background: var(--input-bg);
  color: var(--text-primary);
  font-size: 1rem;
  padding: 0 10px;
}

.participant-weight-group {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  margin-top: 4px;
}

.participant-weight-group label {
  font-size: 0.75rem;
  color: var(--text-secondary);
  white-space: nowrap;
}

.weight-slider {
  flex: 1;
  height: 6px;
  -webkit-appearance: none;
  appearance: none;
  background: var(--slider-track);
  border-radius: 3px;
  outline: none;
}

.weight-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--slider-thumb);
  cursor: pointer;
  border: 2px solid #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,0.3);
}

.weight-slider::-moz-range-thumb {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--slider-thumb);
  cursor: pointer;
  border: 2px solid #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,0.3);
}

.weight-value {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--accent);
  min-width: 32px;
  text-align: center;
}

.btn-remove {
  width: 44px;
  height: 44px;
  border: none;
  border-radius: 8px;
  background: rgba(233, 69, 96, 0.2);
  color: var(--accent);
  font-size: 1.2rem;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.2s;
}

.btn-remove:active {
  background: rgba(233, 69, 96, 0.4);
}

/* ---- Collection Unit ---- */
.unit-group {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.unit-option {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  border: 2px solid var(--input-border);
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-secondary);
  transition: border-color 0.2s, background 0.2s, color 0.2s;
}

.unit-option input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.unit-option:has(input:checked) {
  border-color: var(--accent);
  background: rgba(233, 69, 96, 0.12);
  color: var(--text-primary);
}

.unit-option:has(input:focus-visible) {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ---- Hints & Errors ---- */
.field-hint {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin: 8px 0;
}

.field-hint.center {
  text-align: center;
  margin-bottom: 0;
}

.form-error {
  background: rgba(233, 69, 96, 0.15);
  border: 1px solid var(--accent);
  color: var(--text-primary);
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 12px;
  font-size: 0.9rem;
}

.badge {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 8px;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 600;
  vertical-align: middle;
}

/* ---- Buttons ---- */
.btn {
  display: block;
  width: 100%;
  height: 48px;
  border: none;
  border-radius: 10px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
}

.btn:active {
  transform: scale(0.98);
}

.btn-add {
  background: transparent;
  border: 2px dashed var(--border);
  color: var(--text-secondary);
  margin-top: 8px;
  height: 44px;
}

.btn-add:active {
  border-color: var(--accent);
  color: var(--accent);
}

.btn-line {
  background: #06c755;
  color: #fff;
  height: 52px;
  font-size: 1.05rem;
  margin-top: 12px;
  box-shadow: 0 3px 12px var(--shadow);
}

/* ---- Explanatory content / guides ---- */
.guide-title {
  font-size: 1.3rem;
  line-height: 1.5;
  margin-bottom: 12px;
  color: var(--text-primary);
}

.content {
  font-size: 0.9rem;
  line-height: 1.8;
}

.content h3 {
  font-size: 0.95rem;
  margin: 20px 0 6px;
  padding-left: 8px;
  border-left: 3px solid var(--accent);
}

.content p + p {
  margin-top: 8px;
}

.content ol,
.content ul {
  padding-left: 20px;
}

.content li + li {
  margin-top: 6px;
}

.content table {
  width: 100%;
  border-collapse: collapse;
  margin: 8px 0;
  font-size: 0.85rem;
}

.content th,
.content td {
  border: 1px solid var(--border);
  padding: 6px 8px;
  text-align: left;
}

.content th {
  background: var(--result-bg);
}

.shared-notice {
  max-width: 448px;
  margin: 12px auto 0;
  padding: 10px 12px;
  border-radius: 8px;
  background: rgba(46, 157, 91, 0.2);
  border: 1px solid #2e9d5b;
  font-size: 0.85rem;
  text-align: center;
}

@media (max-width: 480px) {
  .shared-notice {
    margin: 12px 16px 0;
  }
}

/* ---- Bills (1次会・2次会…) ---- */
.bill-tabs {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  margin-bottom: 10px;
  padding-bottom: 2px;
}

.bill-tab {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 76px;
  min-height: 48px;
  padding: 4px 12px;
  border: 2px solid var(--input-border);
  border-radius: 10px;
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
}

.bill-tab small {
  font-size: 0.7rem;
  font-weight: 400;
}

.bill-tab.active {
  border-color: var(--accent);
  background: rgba(233, 69, 96, 0.12);
  color: var(--text-primary);
}

.bill-add {
  border-style: dashed;
}

.bill-name-row {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}

#attendeeBox .field-hint {
  margin-top: 12px;
}

.result-sub {
  display: block;
  font-size: 0.7rem;
  color: var(--text-secondary);
  text-decoration: none;
}

/* ---- Participant count stepper ---- */
.card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}

.card-head h2 {
  margin-bottom: 0;
}

.stepper {
  display: flex;
  align-items: center;
  gap: 4px;
}

.stepper-btn {
  width: 44px;
  height: 44px;
  border: 2px solid var(--input-border);
  border-radius: 10px;
  background: var(--input-bg);
  color: var(--text-primary);
  font-size: 1.3rem;
  cursor: pointer;
}

.stepper-btn:disabled {
  opacity: 0.35;
  cursor: default;
}

.stepper-count {
  min-width: 44px;
  text-align: center;
  font-weight: 700;
}

/* ---- Fixed amount & presets ---- */
.btn-fixed {
  height: 44px;
  padding: 0 10px;
  border: 2px solid var(--input-border);
  border-radius: 8px;
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  flex-shrink: 0;
}

.btn-fixed.active {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.fixed-group {
  width: 100%;
  margin-top: 4px;
}

.fixed-group label {
  min-width: 0 !important;
}

.preset-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  width: 100%;
}

.chip {
  height: 32px;
  padding: 0 9px;
  border: 1px solid var(--input-border);
  border-radius: 16px;
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.75rem;
  cursor: pointer;
  white-space: nowrap;
}

.chip.active {
  border-color: var(--accent);
  color: var(--text-primary);
  background: rgba(233, 69, 96, 0.15);
}

.participant-row {
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

/* ---- Collection check ---- */
button.result-item {
  width: 100%;
  border: none;
  font: inherit;
  color: inherit;
  text-align: left;
  cursor: pointer;
}

.result-item .check {
  width: 24px;
  height: 24px;
  flex-shrink: 0;
  margin-right: 10px;
  border: 2px solid var(--input-border);
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 700;
}

.result-item .check.none {
  visibility: hidden;
}

.result-item .result-name {
  flex: 1;
}

.result-item.paid .check {
  background: #2e9d5b;
  border-color: #2e9d5b;
  color: #fff;
}

.result-item.paid .result-name,
.result-item.paid .result-amount {
  opacity: 0.5;
  text-decoration: line-through;
}

.collect-summary {
  margin-top: 10px;
  padding: 8px 12px;
  border-radius: 8px;
  background: var(--result-bg);
  font-size: 0.85rem;
  text-align: center;
}

.collect-summary:empty {
  display: none;
}

.collect-summary.done {
  background: rgba(46, 157, 91, 0.2);
  font-weight: 600;
}

.badge-muted {
  background: var(--input-border);
}

.btn-restore {
  margin-top: 8px;
  width: 100%;
  height: 36px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: transparent;
  color: var(--accent);
  font-size: 0.8rem;
  cursor: pointer;
}

.btn-secondary {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  height: 40px;
  font-size: 0.85rem;
  margin-top: 8px;
}

/* ---- Toggle Switch ---- */
.toggle-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.toggle-row label:first-child {
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.toggle-switch {
  position: relative;
  width: 52px;
  height: 28px;
  display: inline-block;
}

.toggle-switch input {
  position: absolute;
  opacity: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  cursor: pointer;
  z-index: 1;
}

.toggle-switch input:focus-visible + .toggle-slider {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--toggle-bg);
  border-radius: 28px;
  cursor: pointer;
  transition: background 0.3s;
}

.toggle-slider::before {
  content: '';
  position: absolute;
  width: 22px;
  height: 22px;
  left: 3px;
  top: 3px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.3s;
}

.toggle-switch input:checked + .toggle-slider {
  background: var(--toggle-active);
}

.toggle-switch input:checked + .toggle-slider::before {
  transform: translateX(24px);
}

/* ---- Organizer Settings ---- */
.organizer-select-group {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  margin-top: 12px;
}

.organizer-select-group label {
  font-size: 0.85rem;
  color: var(--text-secondary);
  white-space: nowrap;
}

.organizer-select-group select {
  flex: 1;
  height: 44px;
  border: 1px solid var(--input-border);
  border-radius: 8px;
  background: var(--input-bg);
  color: var(--text-primary);
  font-size: 1rem;
  padding: 0 10px;
}

/* ---- Result ---- */
.result-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  margin-bottom: 6px;
  background: var(--result-bg);
  border-radius: 8px;
}

.result-name {
  font-size: 1rem;
  font-weight: 500;
}

.result-amount {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--accent);
}

.result-total {
  text-align: right;
  padding-top: 8px;
  margin-top: 8px;
  border-top: 1px solid var(--border);
  font-size: 0.9rem;
  color: var(--text-secondary);
}

/* ---- Share / Copy Buttons ---- */
.share-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.btn-copy {
  flex: 1;
  background: transparent;
  border: 2px solid var(--accent);
  color: var(--accent);
  height: 44px;
  font-size: 0.9rem;
  border-radius: 10px;
  transition: background 0.2s, color 0.2s;
}

.btn-link {
  background: transparent;
  color: var(--text-secondary);
  height: 40px;
  font-size: 0.85rem;
  font-weight: 400;
  text-decoration: underline;
  margin: 0 0 12px;
}

.btn-copy:active {
  background: var(--accent);
  color: #fff;
}

.btn-copy.copied {
  background: var(--accent);
  color: #fff;
}

/* ---- History ---- */
.history-item {
  padding: 10px 12px;
  margin-top: 8px;
  background: var(--result-bg);
  border-radius: 8px;
  font-size: 0.85rem;
}

.history-item .history-date {
  color: var(--text-secondary);
  font-size: 0.75rem;
  margin-bottom: 4px;
}

.history-item .history-detail {
  display: flex;
  justify-content: space-between;
}

/* ---- Site navigation (yorozu-craft common layout) ---- */
.site-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 1rem;
  background-color: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
  gap: 0.4rem;
}

.nav-brand {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--accent);
  text-decoration: none;
}

.nav-links {
  list-style: none;
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}

.nav-links a {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.82rem;
}

.nav-links a:hover,
.nav-links a[aria-current="page"] {
  color: var(--accent);
}

@media (max-width: 600px) {
  .site-nav {
    flex-direction: column;
    align-items: flex-start;
  }

  .nav-links {
    gap: 0.6rem;
  }
}

/* ---- Content pages (guide / about / privacy) ---- */
.legal-page {
  padding-top: 1.5rem;
}

.content-section {
  line-height: 1.8;
}

.legal-page h1 {
  font-size: 1.4rem;
  color: var(--accent);
  margin-bottom: 0.3rem;
}

.content-section h2 {
  font-size: 1.05rem;
  margin: 1.5rem 0 0.4rem;
}

.content-section h2:first-child {
  margin-top: 0;
}

.content-section h3 {
  font-size: 0.95rem;
  color: var(--text-primary);
  margin: 1rem 0 0.4rem;
}

.content-section p,
.content-section li {
  font-size: 0.88rem;
  color: var(--text-secondary);
}

.content-section p {
  margin-bottom: 0.5rem;
}

.content-section ul,
.content-section ol {
  padding-left: 1.2rem;
  margin-bottom: 0.5rem;
}

.content-section li {
  margin-bottom: 0.3rem;
}

.content-section strong {
  color: var(--text-primary);
}

.legal-page a {
  color: var(--accent);
}

.last-updated {
  font-size: 0.78rem;
  color: var(--text-secondary);
  margin-bottom: 1rem;
}

.guide-content {
  margin-bottom: 1rem;
}

.guide-step {
  margin-bottom: 0.8rem;
  padding-left: 0.5rem;
  border-left: 3px solid var(--accent);
}

.guide-step h3 {
  margin-top: 0;
  color: var(--accent);
}

.use-cases {
  list-style: none;
  padding-left: 0 !important;
}

.use-cases li::before {
  content: '▸ ';
  color: var(--accent);
}

.faq-list dt {
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-top: 0.8rem;
  padding: 0.3rem 0;
}

.faq-list dt::before {
  content: 'Q. ';
  color: var(--accent);
  font-weight: 700;
}

.faq-list dd {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-left: 0;
  padding: 0.2rem 0 0.5rem 1.2rem;
  border-bottom: 1px solid var(--border);
}

.info-list {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 0.4rem 1.2rem;
  margin: 0.5rem 0 1rem;
  font-size: 0.88rem;
}

.info-list dt { font-weight: 600; color: var(--text-primary); }
.info-list dd { margin: 0; color: var(--text-secondary); }

.guide-link {
  text-align: center;
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin: 4px 0 12px;
}

/* ---- Footer ---- */
.app-footer {
  text-align: center;
  padding: 1rem;
  color: var(--text-secondary);
  font-size: 0.78rem;
  background: var(--footer-bg);
  border-top: 1px solid var(--border);
  margin-top: 0.5rem;
}

.footer-nav ul {
  list-style: none;
  display: flex;
  justify-content: center;
  gap: 0.6rem 1.2rem;
  flex-wrap: wrap;
  margin-bottom: 0.7rem;
}

.footer-nav a {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.8rem;
}

.footer-nav a:hover,
.footer-nav a[aria-current="page"] {
  color: var(--accent);
}

.copyright {
  font-size: 0.72rem;
  color: var(--text-secondary);
  margin-top: 0.3rem;
}

/* ---- Utilities ---- */
.hidden {
  display: none !important;
}

/* ---- Responsive ---- */
@media (min-width: 600px) {
  .container {
    padding: 20px;
  }

  .card {
    padding: 20px;
  }
}
