:root {
  --ink: #17211b;
  --muted: #69756e;
  --paper: #f6f3eb;
  --card: #fffdf8;
  --line: #dedbd1;
  --green: #356859;
  --green-soft: #dbe9e2;
  --coral: #e56b52;
  --shadow: 0 18px 45px rgba(23, 33, 27, .08);
}

* { box-sizing: border-box; }
html { color-scheme: light; }
body { margin: 0; background: var(--paper); color: var(--ink); font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
a { color: var(--green); text-decoration: none; }
button, input, select, textarea { font: inherit; }
button, .primary-button, .secondary-button { cursor: pointer; }

.site-header { min-height: 68px; padding: 0 5vw; display: flex; align-items: center; justify-content: space-between; background: rgba(255,253,248,.94); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; backdrop-filter: blur(10px); }
.brand { color: var(--ink); font-weight: 900; font-size: 1.3rem; letter-spacing: -.04em; }
.site-header nav { display: flex; gap: 18px; align-items: center; font-size: .92rem; }
.site-header form { margin: 0; }
.link-button { border: 0; background: transparent; color: var(--green); padding: 0; }
.flash { max-width: 1100px; margin: 14px auto; padding: 12px 18px; border-radius: 12px; }
.flash.notice { background: var(--green-soft); }.flash.alert, .form-errors, .api-error { background: #fde5df; color: #8a2f1f; }

.login-shell { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(circle at 10% 5%, #e7efe9, transparent 33%), radial-gradient(circle at 90% 90%, #f5d9cd, transparent 30%), var(--paper); }
.login-card { width: min(440px, 100%); padding: 46px; border: 1px solid var(--line); background: rgba(255,253,248,.94); box-shadow: var(--shadow); border-radius: 28px; }
.kapsme-mark { width: 52px; height: 52px; border-radius: 50% 50% 44% 44%; display: grid; place-items: center; color: white; background: var(--coral); box-shadow: inset 0 -8px 0 rgba(0,0,0,.08); margin-bottom: 24px; }
.oauth-note { margin: 18px 0 0; padding-top: 16px; border-top: 1px solid var(--line); color: var(--muted); font-size: .78rem; line-height: 1.5; }
h1, h2, h3, p { margin-top: 0; } h1 { font-size: clamp(2rem, 5vw, 3.6rem); letter-spacing: -.055em; line-height: 1; } h2 { letter-spacing: -.035em; }
.eyebrow { color: var(--coral); text-transform: uppercase; letter-spacing: .13em; font-size: .74rem; font-weight: 800; margin-bottom: 8px; }
.muted { color: var(--muted); }

.stack-form { display: grid; gap: 16px; }.stack-form label { display: grid; gap: 7px; font-weight: 700; font-size: .9rem; }
input, select, textarea { width: 100%; border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; color: var(--ink); background: white; }
input:focus, select:focus, textarea:focus { outline: 3px solid rgba(53,104,89,.15); border-color: var(--green); }
.checkbox { display: flex !important; grid-template-columns: auto 1fr; align-items: center; gap: 9px !important; }.checkbox input { width: auto; }
fieldset { border: 1px solid var(--line); border-radius: 14px; padding: 14px; } legend { font-weight: 800; padding: 0 5px; }
.primary-button, .secondary-button { display: inline-flex; justify-content: center; align-items: center; border-radius: 12px; padding: 11px 16px; border: 1px solid var(--green); font-weight: 800; }
.primary-button { background: var(--green); color: white; }.secondary-button { color: var(--green); background: transparent; }

.app-shell, .admin-shell { width: min(1100px, calc(100% - 32px)); margin: 32px auto 80px; }
.app-shell { max-width: 760px; }
.hero-card { display: flex; justify-content: space-between; align-items: center; gap: 20px; padding: 30px; border-radius: 28px; color: white; background: linear-gradient(135deg, #274f44, #487f6f); box-shadow: var(--shadow); }.hero-card h1 { font-size: clamp(2rem, 7vw, 3.8rem); max-width: 520px; margin-bottom: 0; }.hero-card .eyebrow { color: #f8b09f; }
.score-ring { flex: 0 0 92px; height: 92px; display: grid; place-items: center; border: 8px solid rgba(255,255,255,.25); border-top-color: white; border-radius: 50%; font-size: 1.2rem; font-weight: 900; }
.app-tabs { display: grid; grid-template-columns: repeat(4, 1fr); margin: 22px 0; padding: 5px; border-radius: 14px; background: #e9e5dc; }.app-tabs button { border: 0; background: transparent; padding: 10px 5px; border-radius: 10px; color: var(--muted); font-size: .86rem; }.app-tabs button.active { background: var(--card); color: var(--ink); box-shadow: 0 3px 12px rgba(0,0,0,.06); font-weight: 800; }
.day-nav, .section-heading { display: flex; justify-content: space-between; align-items: center; gap: 15px; }.day-nav { margin: 28px 0 18px; text-align: center; }.day-nav button { width: 42px; height: 42px; border: 1px solid var(--line); background: var(--card); border-radius: 50%; }.day-nav small { display: block; color: var(--muted); margin-top: 3px; }
.habit-list { display: grid; gap: 12px; }.habit-item, .panel { background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 18px; box-shadow: 0 7px 22px rgba(23,33,27,.04); }.habit-item { display: flex; align-items: center; gap: 14px; }.habit-item .content { flex: 1; min-width: 0; }.habit-item h3 { margin-bottom: 4px; font-size: 1rem; }.habit-item p { margin: 0; color: var(--muted); font-size: .86rem; }.habit-item.completed { opacity: .66; }.habit-item.completed h3 { text-decoration: line-through; }.habit-item.paused { background: #efede7; }.check-button { width: 44px; height: 44px; border-radius: 50%; border: 2px solid var(--green); color: transparent; background: transparent; font-weight: 900; }.completed .check-button { background: var(--green); color: white; }.badge { font-size: .72rem; padding: 5px 8px; border-radius: 99px; background: var(--green-soft); color: var(--green); font-weight: 800; }
.panel { margin-bottom: 16px; }.panel h3 { margin-bottom: 8px; }.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }.form-actions, .inline-form { display: flex; gap: 10px; align-items: center; }.inline-form { margin-bottom: 18px; }.inline-form input { flex: 1; }
.section-heading { margin: 28px 0 16px; }.section-heading h1, .section-heading h2 { margin-bottom: 0; }.api-error { padding: 12px 16px; border-radius: 12px; }.empty-state { text-align: center; padding: 42px 20px; color: var(--muted); }

.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 24px; }.stats-grid article { padding: 22px; border-radius: 18px; background: var(--card); border: 1px solid var(--line); }.stats-grid strong { display: block; font-size: 2rem; }.stats-grid span { color: var(--muted); font-size: .86rem; }
table { width: 100%; border-collapse: collapse; } th, td { padding: 12px 10px; border-bottom: 1px solid var(--line); text-align: left; } th { color: var(--muted); font-size: .76rem; text-transform: uppercase; letter-spacing: .08em; }.admin-list { list-style: none; padding: 0; }.admin-list li { display: flex; justify-content: space-between; padding: 12px 0; border-bottom: 1px solid var(--line); }.admin-list span { color: var(--muted); }

@media (max-width: 700px) {
  .site-header { position: static; padding: 16px; align-items: flex-start; }.site-header nav { gap: 9px; flex-wrap: wrap; justify-content: flex-end; }
  .app-shell, .admin-shell { width: min(100% - 20px, 760px); margin-top: 16px; }.hero-card { padding: 23px; }.score-ring { flex-basis: 72px; height: 72px; border-width: 6px; }
  .app-tabs button { font-size: .72rem; }.form-grid, .stats-grid { grid-template-columns: 1fr 1fr; }.panel { overflow-x: auto; }
}

@media (max-height: 720px) {
  .oauth-shell { min-height: 100dvh; place-items: start center; padding: 12px 12px calc(88px + env(safe-area-inset-bottom)); }
  .oauth-shell .login-card { padding: 24px; border-radius: 22px; }
  .oauth-shell .kapsme-mark { width: 40px; height: 40px; margin-bottom: 14px; }
  .oauth-shell h1 { font-size: 2rem; margin-bottom: 12px; }
  .oauth-shell .muted { font-size: .9rem; margin-bottom: 14px; }
  .oauth-shell .stack-form { gap: 11px; }
  .oauth-shell .oauth-note { margin-top: 12px; padding-top: 10px; }
}
