:root {
  --ink: #16202A;
  --paper: #EEF0E7;
  --paper-raised: #F8F9F3;
  --growth: #2F6D5B;
  --growth-dark: #234F42;
  --gold: #D9A22C;
  --danger: #B5473A;
  --line: #D8DACE;
  --text-dim: #5B6560;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Noto Sans JP", sans-serif;
  background: var(--paper);
  color: var(--ink);
}

h1, h2, h3 {
  font-family: "Noto Serif JP", serif;
  margin: 0;
  letter-spacing: 0.01em;
}

.hidden { display: none !important; }

input {
  font-family: inherit;
  font-size: 1rem;
  padding: 0.6rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: var(--paper-raised);
  color: var(--ink);
  width: 100%;
}
input:focus {
  outline: none;
  border-color: var(--growth);
  box-shadow: 0 0 0 3px rgba(47,109,91,0.15);
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
}

/* ---------- 認証画面 ---------- */
.auth-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}

.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--paper-raised);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 2.5rem 2.25rem;
}

.auth-kicker {
  color: var(--growth);
  font-size: 0.85rem;
  margin: 0 0 0.4rem;
}

.auth-card h1 {
  font-size: 1.7rem;
  color: var(--ink);
  margin: 0;
}

.auth-banner {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 6px;
}

.auth-lede {
  color: var(--text-dim);
  font-size: 0.92rem;
  margin: 0.6rem 0 1.6rem;
  line-height: 1.6;
}

.auth-tabs {
  display: flex;
  border-bottom: 1px solid var(--line);
  margin-bottom: 1.4rem;
}

.auth-tab {
  background: none;
  padding: 0.6rem 0;
  margin-right: 1.6rem;
  font-size: 0.95rem;
  color: var(--text-dim);
  border-bottom: 2px solid transparent;
}

.auth-tab.active {
  color: var(--growth-dark);
  border-bottom-color: var(--growth);
  font-weight: 700;
}

.auth-form { display: flex; flex-direction: column; gap: 1rem; }
.auth-form label { font-size: 0.85rem; color: var(--text-dim); display: flex; flex-direction: column; gap: 0.35rem; }

.auth-form button {
  margin-top: 0.4rem;
  background: var(--growth);
  color: var(--paper-raised);
  padding: 0.75rem;
  border-radius: 3px;
  font-size: 0.95rem;
  font-weight: 700;
  transition: background 0.15s ease;
}
.auth-form button:hover { background: var(--growth-dark); }

.auth-error { color: var(--danger); font-size: 0.85rem; min-height: 1.1em; margin: 0; }

/* ---------- アプリ画面 ---------- */
.app-screen {
  display: grid;
  grid-template-columns: 220px 1fr;
  min-height: 100vh;
}

.side-nav {
  background: var(--ink);
  color: var(--paper);
  padding: 1.8rem 1.2rem;
  display: flex;
  flex-direction: column;
}

.brand {
  margin-bottom: 2.2rem;
}

.brand-icon {
  display: block;
  width: 64px;
  height: 64px;
  border-radius: 12px;
}

.nav-avatar-mobile {
  display: none;
  background: none;
  padding: 0;
}
.nav-avatar-img {
  display: block;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
}

.nav-item {
  background: none;
  color: rgba(238,240,231,0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.65rem;
  border-radius: 3px;
  margin-bottom: 0.2rem;
}
.nav-item:hover { color: var(--paper); background: rgba(238,240,231,0.06); }
.nav-item.active {
  background: rgba(238,240,231,0.1);
  color: var(--paper);
  border-left: 3px solid var(--gold);
  padding-left: calc(0.65rem - 3px);
}
.nav-icon { width: 22px; height: 22px; flex-shrink: 0; }

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

.nav-spacer { flex: 1; }
.nav-item.logout { color: rgba(238,240,231,0.45); }

.main-area {
  padding: 2.6rem 3rem;
  max-width: 920px;
}

.view { display: none; }
.view.active { display: block; }

.view-header { margin-bottom: 1.8rem; }
.view-header h2 { font-size: 1.5rem; }
.view-sub { color: var(--text-dim); font-size: 0.88rem; margin: 0.4rem 0 0; }

.measure-form, .goal-form {
  display: flex;
  gap: 1rem;
  align-items: end;
  flex-wrap: wrap;
  background: var(--paper-raised);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 1.4rem;
  margin-bottom: 1.8rem;
}
.measure-form label, .goal-form label {
  font-size: 0.82rem;
  color: var(--text-dim);
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  flex: 1;
  min-width: 140px;
}
.measure-form button, .goal-form button {
  background: var(--growth);
  color: var(--paper-raised);
  padding: 0.7rem 1.3rem;
  border-radius: 3px;
  font-weight: 700;
  white-space: nowrap;
}
.measure-form button:hover, .goal-form button:hover { background: var(--growth-dark); }

.progress-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 1rem;
  margin-bottom: 1.8rem;
}

.progress-card {
  background: var(--paper-raised);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 1.2rem;
}
.progress-card .label { font-size: 0.8rem; color: var(--text-dim); margin-bottom: 0.5rem; }
.progress-card .value { font-family: "Noto Serif JP", serif; font-size: 1.6rem; }
.progress-card .value.negative { color: var(--growth-dark); }
.progress-card .value.positive { color: var(--danger); }
.progress-card .sub { font-size: 0.78rem; color: var(--text-dim); margin-top: 0.3rem; }
.progress-card .value.empty { color: var(--text-dim); font-size: 1rem; }

.goal-progress-card, .current-goal {
  background: var(--ink);
  color: var(--paper);
  border-radius: 6px;
  padding: 1.5rem 1.6rem;
  margin-bottom: 1rem;
}
.goal-progress-card .headline, .current-goal .headline {
  font-family: "Noto Serif JP", serif;
  font-size: 1.3rem;
  margin-bottom: 0.3rem;
}
.goal-progress-card .detail, .current-goal .detail {
  font-size: 0.85rem;
  color: rgba(238,240,231,0.65);
}
.goal-progress-card .empty, .current-goal .empty {
  color: rgba(238,240,231,0.6);
  font-size: 0.9rem;
}

.ranking-controls { margin-bottom: 1.5rem; }
.segmented { display: inline-flex; border: 1px solid var(--line); border-radius: 20px; overflow: hidden; }
.seg {
  background: var(--paper-raised);
  padding: 0.5rem 1.2rem;
  font-size: 0.85rem;
  color: var(--text-dim);
}
.seg.active { background: var(--growth); color: var(--paper-raised); font-weight: 700; }

.ranking-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.8rem;
}
.ranking-col h3 { font-size: 1rem; margin-bottom: 0.8rem; color: var(--text-dim); font-weight: 700; }

.ranking-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.5rem; }
.rank-row {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  background: var(--paper-raised);
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 0.7rem 0.9rem;
}
.rank-row.first { border-color: var(--gold); background: #FBF3DF; }
.rank-num {
  font-family: "Noto Serif JP", serif;
  font-size: 1.1rem;
  width: 1.6rem;
  color: var(--text-dim);
}
.rank-row.first .rank-num { color: var(--gold); }
.rank-name { flex: 1; font-size: 0.92rem; }
.rank-value { font-weight: 700; color: var(--growth-dark); font-size: 0.95rem; }

/* ---------- 通知 ---------- */

.reminder-banner {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  background: #FBF3DF;
  border: 1px solid var(--gold);
  border-radius: 6px;
  padding: 0.9rem 1.1rem;
  margin-bottom: 1.4rem;
  font-size: 0.9rem;
}
.reminder-banner::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--gold);
  flex-shrink: 0;
}

.weight-warning-banner {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  background: #FBEAE7;
  border: 1px solid var(--danger);
  border-radius: 6px;
  padding: 0.9rem 1.1rem;
  margin-bottom: 1.4rem;
  font-size: 0.9rem;
  color: var(--danger);
}
.weight-warning-banner::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--danger);
  flex-shrink: 0;
}

.notify-status {
  background: var(--ink);
  color: var(--paper);
  border-radius: 6px;
  padding: 1.4rem 1.6rem;
  margin-bottom: 1.4rem;
}
.notify-status .headline {
  font-family: "Noto Serif JP", serif;
  font-size: 1.2rem;
  margin-bottom: 0.35rem;
}
.notify-status .detail {
  font-size: 0.85rem;
  color: rgba(238, 240, 231, 0.65);
  line-height: 1.6;
}

.switch-label {
  flex-direction: row !important;
  align-items: center;
  gap: 0.55rem !important;
  font-size: 0.92rem !important;
  color: var(--ink) !important;
  flex: 0 0 auto !important;
  padding-bottom: 0.6rem;
}
.switch-label input {
  width: auto;
  accent-color: var(--growth);
  transform: scale(1.2);
}

.notify-actions {
  display: flex;
  gap: 0.7rem;
  flex-wrap: wrap;
  margin-bottom: 0.8rem;
}

.secondary-btn {
  background: var(--paper-raised);
  border: 1px solid var(--growth);
  color: var(--growth-dark);
  padding: 0.6rem 1.1rem;
  border-radius: 3px;
  font-size: 0.88rem;
  font-weight: 500;
  transition: background 0.15s ease;
}
.secondary-btn:hover { background: #E3EBE7; }
.secondary-btn.quiet { border-color: var(--line); color: var(--text-dim); }
.secondary-btn.quiet:hover { background: #E8E9E1; }

.notify-message {
  font-size: 0.86rem;
  min-height: 1.2em;
  margin: 0;
  color: var(--growth-dark);
}
.notify-message.error { color: var(--danger); }

/* ---------- リンク風ボタン・OAuth・バナー・プロフィール ---------- */

.link-btn {
  background: none;
  color: var(--growth-dark);
  font-size: 0.85rem;
  padding: 0;
  text-decoration: underline;
  align-self: flex-start;
}
.link-btn:hover { color: var(--growth); }

.rank-name.link-btn {
  text-decoration: none;
  color: var(--ink);
  font-size: 0.92rem;
  cursor: pointer;
}
.rank-name.link-btn:hover { color: var(--growth-dark); text-decoration: underline; }

.auth-note { color: var(--growth-dark); font-size: 0.85rem; margin: 0; }
.auth-note.error { color: var(--danger); }

.oauth-buttons {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin-top: 1.4rem;
}
.oauth-btn { width: 100%; }

.verify-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  background: #FBF3DF;
  border: 1px solid var(--gold);
  border-radius: 6px;
  padding: 0.8rem 1.1rem;
  margin-bottom: 1.4rem;
  font-size: 0.88rem;
}

.follow-btn { white-space: nowrap; }

.account-subheading {
  font-size: 0.95rem;
  color: var(--text-dim);
  margin: 1.6rem 0 0.6rem;
}

.ranking-controls {
  display: flex;
  gap: 0.8rem;
  flex-wrap: wrap;
}

.linked-provider-row {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  background: var(--paper-raised);
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 0.7rem 0.9rem;
  margin-bottom: 0.5rem;
}
.linked-provider-row .provider-name { flex: 1; font-size: 0.92rem; }
.linked-provider-row .provider-status { font-size: 0.82rem; color: var(--growth-dark); }

.avatar-presets {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(52px, 1fr));
  gap: 0.5rem;
  margin-bottom: 1rem;
}
.avatar-preset-btn {
  padding: 3px;
  border: 2px solid transparent;
  border-radius: 50%;
  background: var(--paper-raised);
  cursor: pointer;
  line-height: 0;
  transition: border-color 0.15s;
}
.avatar-preset-btn:hover { border-color: var(--line); }
.avatar-preset-btn.selected { border-color: var(--growth-dark); }
.avatar-preset-btn img {
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 50%;
  object-fit: cover;
  display: block;
}

.avatar-field {
  flex-basis: 100%;
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}
.avatar-preview {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid var(--line);
  background: var(--paper);
}

.empty-note { color: var(--text-dim); font-size: 0.85rem; }
.error-note { color: var(--danger); }

@media (max-width: 720px) {
  .app-screen { grid-template-columns: 1fr; }
  .side-nav {
    flex-direction: row;
    align-items: center;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding: 0.8rem 1rem;
  }
  .brand { display: none; }
  .nav-avatar-mobile {
    display: flex;
    margin-right: 0.8rem;
    padding-right: 0.8rem;
    flex-shrink: 0;
    position: sticky;
    left: 0;
    background: var(--ink);
    z-index: 1;
  }
  .nav-spacer { display: none; }
  .side-nav .nav-item {
    flex-shrink: 0;
    white-space: nowrap;
  }
  .nav-item.active {
    border-left: none;
    border-bottom: 3px solid var(--gold);
    padding-left: 0.65rem;
    padding-bottom: calc(0.65rem - 3px);
  }
  .main-area { padding: 1.6rem; }
  .ranking-columns { grid-template-columns: 1fr; }
}
