/* ファイルパス: public/css/style.css */

:root {
  --bg: #f8fafc;
  --surface: #ffffff;
  --surface-soft: #f9fafb;
  --surface-blue: #f5f7ff;
  --border: #e5e7eb;
  --border-strong: #d9def0;
  --text: #111827;
  --text-muted: #667085;
  --text-soft: #98a2b3;
  --primary: #4f46e5;
  --primary-2: #2563eb;
  --primary-dark: #3730a3;
  --primary-soft: #eef2ff;
  --success: #16a34a;
  --success-soft: #ecfdf3;
  --danger: #dc2626;
  --danger-soft: #fef2f2;
  --warning: #d97706;
  --warning-soft: #fffbeb;
  --info: #2563eb;
  --info-soft: #eff6ff;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.04);
  --shadow-md: 0 10px 30px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 18px 50px rgba(15, 23, 42, 0.10);
  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 18px;
  --radius-xl: 24px;
  --header-h: 68px;
  --bottom-nav-h: 72px;
  --content-max: 1080px;
  --study-max: 820px;
  --font: Inter, "Noto Sans JP", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
  text-size-adjust: 100%;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.6;
  color: var(--text);
  background:
    radial-gradient(circle at 12% 0%, rgba(79, 70, 229, 0.06), transparent 27rem),
    linear-gradient(180deg, #ffffff 0%, var(--bg) 44%, var(--bg) 100%);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

body.study-mode .bottom-nav {
  transform: translateY(110%);
  pointer-events: none;
}

a {
  color: inherit;
  text-decoration: none;
}

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

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.52;
}

svg {
  display: block;
}

.app-shell {
  min-height: 100vh;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 40;
  height: var(--header-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 max(18px, env(safe-area-inset-left));
  border-bottom: 1px solid rgba(229, 231, 235, 0.9);
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.brand,
.auth-brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
}

.brand-mark {
  width: 40px;
  height: 40px;
  flex: 0 0 40px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  color: #fff;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-2) 100%);
  box-shadow: 0 10px 24px rgba(79, 70, 229, 0.24);
  font-size: 14px;
  font-weight: 900;
  letter-spacing: -0.04em;
}

.brand-copy {
  display: flex;
  flex-direction: column;
  min-width: 0;
  line-height: 1.15;
}

.brand-copy strong {
  font-size: 16px;
  font-weight: 850;
  letter-spacing: -0.025em;
}

.brand-copy small {
  margin-top: 4px;
  color: var(--text-muted);
  font-size: 12px;
  letter-spacing: 0.02em;
}

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

.sync-indicator {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 34px;
  padding: 0 11px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: #fff;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.sync-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 0 3px rgba(22, 163, 74, 0.10);
}

.sync-indicator.is-offline .sync-dot,
.sync-indicator.is-pending .sync-dot {
  background: var(--warning);
  box-shadow: 0 0 0 3px rgba(217, 119, 6, 0.10);
}

.icon-button {
  width: 42px;
  height: 42px;
  display: inline-grid;
  place-items: center;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
  color: var(--text-muted);
  box-shadow: var(--shadow-sm);
}

.icon-button:hover {
  color: var(--primary);
  border-color: #cfd4ff;
  background: #fbfbff;
}

.icon-button svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.app-view {
  width: min(100%, calc(var(--content-max) + 40px));
  min-height: calc(100vh - var(--header-h));
  margin: 0 auto;
  padding: 26px 20px calc(var(--bottom-nav-h) + 30px);
  outline: none;
}

.page-shell {
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
}

.page-title-wrap {
  min-width: 0;
}

.eyebrow {
  display: inline-block;
  margin-bottom: 6px;
  color: var(--primary);
  font-size: 12px;
  font-weight: 850;
  letter-spacing: 0.12em;
}

.page-title {
  margin: 0;
  color: #172033;
  font-size: clamp(26px, 5vw, 34px);
  line-height: 1.2;
  letter-spacing: -0.045em;
}

.page-subtitle {
  margin: 8px 0 0;
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1.75;
}

.card {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.card-soft {
  border: 1px solid #e4e7ff;
  border-radius: var(--radius-lg);
  background: linear-gradient(135deg, #fff 0%, var(--surface-blue) 100%);
}

.section-title {
  margin: 0;
  color: #27364b;
  font-size: 17px;
  font-weight: 850;
  letter-spacing: -0.02em;
}

.section-note {
  margin: 4px 0 0;
  color: var(--text-muted);
  font-size: 13px;
}

.btn {
  min-height: 44px;
  padding: 0 17px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
  color: var(--text);
  box-shadow: var(--shadow-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 800;
  line-height: 1.2;
  transition: transform 0.16s ease, border-color 0.16s ease, background 0.16s ease, box-shadow 0.16s ease;
}

.btn:hover {
  border-color: var(--border-strong);
  background: #fcfcff;
}

.btn:active {
  transform: translateY(1px);
}

.btn-primary {
  border-color: var(--primary);
  color: #fff;
  background: linear-gradient(135deg, var(--primary) 0%, #5b35f5 100%);
  box-shadow: 0 10px 22px rgba(79, 70, 229, 0.22);
}

.btn-primary:hover {
  border-color: #4338ca;
  background: linear-gradient(135deg, #4338ca 0%, #4f2ddd 100%);
}

.btn-soft {
  border-color: #d9ddff;
  color: var(--primary);
  background: var(--primary-soft);
  box-shadow: none;
}

.btn-ghost {
  border-color: transparent;
  background: transparent;
  box-shadow: none;
  color: var(--text-muted);
}

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

.btn-wide {
  width: 100%;
}

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

.input,
.select,
.textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
  color: var(--text);
  outline: none;
  transition: border-color 0.16s ease, box-shadow 0.16s ease;
}

.input,
.select {
  min-height: 46px;
  padding: 0 14px;
}

.textarea {
  min-height: 130px;
  padding: 12px 14px;
  resize: vertical;
}

.input:focus,
.select:focus,
.textarea:focus {
  border-color: #a5b4fc;
  box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.09);
}

.form-field {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.form-field > span,
.form-label {
  color: #475467;
  font-size: 13px;
  font-weight: 800;
}

.help-text {
  color: var(--text-muted);
  font-size: 12px;
  line-height: 1.6;
}

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 27px;
  padding: 0 10px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.tag.success {
  color: var(--success);
  background: var(--success-soft);
}

.tag.warning {
  color: var(--warning);
  background: var(--warning-soft);
}

.tag.danger {
  color: var(--danger);
  background: var(--danger-soft);
}

.metric {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.metric-label {
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 700;
}

.metric-value {
  color: #172033;
  font-size: 26px;
  font-weight: 900;
  letter-spacing: -0.045em;
}

.metric-sub {
  color: var(--text-muted);
  font-size: 12px;
}

.progress-track {
  width: 100%;
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #edf0f5;
}

.progress-bar {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--primary) 0%, var(--primary-2) 100%);
  transition: width 0.25s ease;
}

.empty-state,
.loading-state,
.error-state {
  min-height: 260px;
  padding: 36px 24px;
  display: grid;
  place-items: center;
  text-align: center;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.72);
}

.state-inner {
  max-width: 480px;
}

.state-inner h2 {
  margin: 14px 0 4px;
  font-size: 20px;
}

.state-inner p {
  margin: 0 0 18px;
  color: var(--text-muted);
}

.state-icon {
  width: 48px;
  height: 48px;
  margin: 0 auto;
  display: grid;
  place-items: center;
  border-radius: 14px;
  color: var(--primary);
  background: var(--primary-soft);
  font-size: 20px;
  font-weight: 900;
}

.spinner {
  width: 28px;
  height: 28px;
  margin: 0 auto;
  border: 3px solid #e5e7eb;
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.bottom-nav {
  position: fixed;
  left: 50%;
  bottom: max(10px, env(safe-area-inset-bottom));
  z-index: 50;
  width: min(560px, calc(100% - 20px));
  min-height: 62px;
  transform: translateX(-50%);
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 4px;
  padding: 6px;
  border: 1px solid rgba(217, 222, 240, 0.96);
  border-radius: 19px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 16px 42px rgba(15, 23, 42, 0.14);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  transition: transform 0.2s ease;
}

.nav-link {
  min-height: 50px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  border-radius: 14px;
  color: #667085;
  font-size: 12px;
  font-weight: 800;
}

.nav-link svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.nav-link.active {
  color: var(--primary);
  background: var(--primary-soft);
}

.toast-region {
  position: fixed;
  right: 18px;
  bottom: calc(var(--bottom-nav-h) + 24px);
  z-index: 80;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}

.toast {
  width: min(380px, calc(100vw - 36px));
  padding: 13px 15px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.97);
  box-shadow: var(--shadow-lg);
  color: #344054;
  font-size: 13px;
  font-weight: 700;
  animation: toast-in 0.2s ease both;
}

.toast.success {
  border-left: 4px solid var(--success);
}

.toast.error {
  border-left: 4px solid var(--danger);
}

.toast.warning {
  border-left: 4px solid var(--warning);
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.divider {
  height: 1px;
  background: var(--border);
}

.kicker {
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: #fff;
}

.table {
  width: 100%;
  border-collapse: collapse;
}

.table th,
.table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: middle;
}

.table th {
  background: #fbfcff;
  color: #475467;
  font-size: 12px;
  font-weight: 850;
}

.table td {
  color: #344054;
  font-size: 13px;
}

.table tr:last-child td {
  border-bottom: none;
}

@media (min-width: 900px) {
  .app-header {
    padding-left: 28px;
    padding-right: 28px;
  }

  .app-view {
    padding-top: 34px;
    padding-bottom: 104px;
  }

  .bottom-nav {
    bottom: 18px;
  }
}

@media (max-width: 560px) {
  :root {
    --header-h: 62px;
  }

  .app-header {
    padding-left: 14px;
    padding-right: 14px;
  }

  .brand-mark {
    width: 36px;
    height: 36px;
    flex-basis: 36px;
    border-radius: 11px;
  }

  .brand-copy strong {
    font-size: 15px;
  }

  .brand-copy small {
    display: none;
  }

  .sync-indicator {
    min-height: 32px;
    padding: 0 9px;
  }

  .sync-indicator span:last-child {
    display: none;
  }

  .icon-button {
    width: 40px;
    height: 40px;
  }

  .app-view {
    padding: 20px 14px 96px;
  }

  .page-head {
    flex-direction: column;
    gap: 14px;
  }

  .button-row > .btn {
    flex: 1 1 auto;
  }

  .toast-region {
    left: 14px;
    right: 14px;
    bottom: 88px;
  }

  .toast {
    width: 100%;
  }

  .table-wrap {
    border-radius: 12px;
  }
}
