:root {
  --bg: #f4f1eb;
  --surface: #fffdf9;
  --surface-2: #f8f5ef;
  --ink: #262a28;
  --muted: #777b76;
  --line: #e6e1d8;
  --sage: #809487;
  --sage-soft: #e6ede7;
  --lavender: #8b849a;
  --lavender-soft: #ece9f1;
  --peach: #b78972;
  --peach-soft: #f2e7e0;
  --danger: #a76666;
  --danger-soft: #f3e5e3;
  --shadow: 0 20px 55px rgba(48, 46, 40, .08);
  --radius-xl: 28px;
  --radius-lg: 21px;
  --radius-md: 15px;
  --sidebar: 248px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: var(--bg);
  font-family: "DM Sans", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input { font: inherit; }
button { color: inherit; }
button:focus-visible, input:focus-visible { outline: 3px solid rgba(128, 148, 135, .25); outline-offset: 2px; }
.hidden { display: none !important; }

/* Auth */
.auth-screen { min-height: 100vh; padding: 30px clamp(20px, 5vw, 72px) 50px; }
.auth-brand, .brand { display: inline-flex; align-items: center; gap: 12px; color: inherit; text-decoration: none; }
.auth-brand strong, .brand strong { display: block; font-family: Manrope, sans-serif; font-size: 16px; }
.auth-brand small, .brand small { display: block; color: var(--muted); font-size: 11px; margin-top: 2px; }
.brand-mark, .loading-mark {
  width: 42px; height: 42px; border-radius: 14px; display: grid; place-items: center;
  background: var(--ink); color: #fff; font: 800 17px Manrope, sans-serif;
}
.auth-layout { min-height: calc(100vh - 100px); display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(360px, 480px); gap: clamp(44px, 8vw, 120px); align-items: center; max-width: 1180px; margin: 0 auto; }
.auth-intro { max-width: 650px; }
.auth-intro h1 { margin: 20px 0 18px; font: 800 clamp(46px, 7vw, 78px)/.98 Manrope, sans-serif; letter-spacing: -.055em; }
.auth-intro > p { max-width: 610px; color: var(--muted); font-size: 18px; line-height: 1.7; }
.soft-label, .section-kicker, .eyebrow { text-transform: uppercase; letter-spacing: .14em; font-size: 11px; font-weight: 700; color: var(--sage); }
.auth-principles { margin-top: 34px; display: grid; gap: 12px; }
.auth-principles > div, .legend-card > div { display: flex; align-items: center; gap: 14px; }
.auth-principles p, .legend-card p { margin: 0; }
.auth-principles strong, .legend-card strong { display: block; font-size: 14px; }
.auth-principles small, .legend-card small { display: block; color: var(--muted); margin-top: 3px; line-height: 1.35; }
.auth-card { background: rgba(255,253,249,.92); border: 1px solid rgba(255,255,255,.9); border-radius: 30px; padding: 28px; box-shadow: var(--shadow); backdrop-filter: blur(16px); }
.auth-tabs { display: grid; grid-template-columns: 1fr 1fr; background: var(--surface-2); padding: 5px; border-radius: 14px; margin-bottom: 28px; }
.auth-tab { border: 0; background: transparent; border-radius: 10px; padding: 11px; cursor: pointer; color: var(--muted); font-weight: 700; }
.auth-tab.active { background: var(--surface); color: var(--ink); box-shadow: 0 4px 14px rgba(44,44,40,.06); }
.auth-form { display: none; gap: 16px; }
.auth-form.active { display: grid; }
.form-heading { margin-bottom: 2px; }
.form-heading h2 { margin: 0 0 8px; font: 750 27px/1.15 Manrope, sans-serif; letter-spacing: -.03em; }
.form-heading p { margin: 0; color: var(--muted); line-height: 1.55; }
.auth-form label, .modal label { display: grid; gap: 8px; color: #555b56; font-size: 13px; font-weight: 700; }
.auth-form input, .modal input[type="text"], .modal input:not([type]) {
  width: 100%; border: 1px solid var(--line); background: #fff; color: var(--ink);
  border-radius: 14px; padding: 14px 15px; outline: none;
}
.auth-form input:focus, .modal input:focus { border-color: var(--sage); box-shadow: 0 0 0 4px rgba(128,148,135,.12); }
.form-message { min-height: 20px; margin: 14px 0 0; color: var(--danger); font-size: 13px; text-align: center; }

/* Shell */
.app-shell { min-height: 100vh; }
.sidebar { position: fixed; inset: 0 auto 0 0; width: var(--sidebar); padding: 26px 20px; background: rgba(255,253,249,.78); border-right: 1px solid var(--line); backdrop-filter: blur(18px); z-index: 20; display: flex; flex-direction: column; }
.brand { padding: 0 8px; }
.side-nav { display: grid; gap: 8px; margin-top: 42px; }
.nav-item { border: 0; background: transparent; border-radius: 14px; padding: 13px 14px; display: flex; align-items: center; gap: 14px; cursor: pointer; color: var(--muted); font-weight: 600; text-align: left; }
.nav-item span { font-size: 10px; letter-spacing: .08em; color: #a4a7a1; }
.nav-item:hover, .nav-item.active { background: var(--sage-soft); color: var(--ink); }
.nav-item.active span { color: var(--sage); }
.sidebar-note { margin-top: auto; padding: 18px; border-radius: 18px; background: var(--lavender-soft); }
.sidebar-note small { color: var(--lavender); text-transform: uppercase; letter-spacing: .12em; font-weight: 700; }
.sidebar-note p { margin: 9px 0 0; color: #625d6a; font-size: 13px; line-height: 1.5; }
.main-content { margin-left: var(--sidebar); padding: 25px clamp(24px, 4vw, 62px) 95px; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 34px; }
.topbar h1 { margin: 6px 0 0; font: 750 clamp(25px, 3vw, 34px)/1.1 Manrope, sans-serif; letter-spacing: -.04em; }
.eyebrow { margin: 0; }
.profile-menu { position: relative; display: flex; align-items: center; gap: 10px; }
.profile-button { display: flex; align-items: center; gap: 11px; border: 1px solid var(--line); background: var(--surface); border-radius: 16px; padding: 7px 12px 7px 7px; cursor: pointer; }
.profile-button > span:first-child { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; background: var(--peach-soft); color: var(--peach); font-weight: 800; font-size: 12px; }
.profile-copy { text-align: left; }
.profile-copy strong, .profile-copy small { display: block; }
.profile-copy strong { font-size: 13px; }
.profile-copy small { color: var(--muted); font-size: 10px; margin-top: 2px; max-width: 160px; overflow: hidden; text-overflow: ellipsis; }
.profile-popover { position: absolute; right: 0; top: calc(100% + 9px); background: var(--surface); border: 1px solid var(--line); border-radius: 13px; min-width: 150px; box-shadow: var(--shadow); padding: 6px; z-index: 30; }
.profile-popover button { width: 100%; border: 0; background: transparent; text-align: left; padding: 10px 12px; border-radius: 9px; cursor: pointer; }
.profile-popover button:hover { background: var(--surface-2); }
.view { display: none; animation: fade .22s ease; }
.view.active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } }

/* Common */
.primary-button, .ghost-button, .text-button, .panel-footer-button, .filter-chip, .period-switch button, .status-button, .memory-button {
  border: 0; cursor: pointer; font-weight: 700;
}
.primary-button { background: var(--ink); color: white; border-radius: 13px; padding: 12px 17px; }
.primary-button:hover { transform: translateY(-1px); box-shadow: 0 8px 20px rgba(38,42,40,.15); }
.ghost-button { background: var(--surface); border: 1px solid var(--line); border-radius: 13px; padding: 11px 15px; }
.text-button { background: transparent; color: var(--sage); padding: 5px; }
.full-width { width: 100%; }
.hero-card { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 30px; align-items: center; background: linear-gradient(135deg, #e6ede7 0%, #eeece4 55%, #eee8e8 100%); border-radius: var(--radius-xl); padding: clamp(28px, 4vw, 48px); min-height: 240px; overflow: hidden; position: relative; }
.hero-card::after { content: ""; position: absolute; width: 240px; height: 240px; border-radius: 50%; right: -80px; bottom: -130px; border: 40px solid rgba(255,255,255,.22); }
.hero-copy { position: relative; z-index: 1; }
.hero-copy h2 { max-width: 680px; margin: 13px 0 12px; font: 750 clamp(30px, 4vw, 48px)/1.06 Manrope, sans-serif; letter-spacing: -.045em; }
.hero-copy p { max-width: 620px; margin: 0; color: #626964; line-height: 1.65; }
.hero-progress { position: relative; z-index: 1; display: grid; justify-items: center; gap: 9px; }
.progress-ring { --progress: 0deg; width: 126px; height: 126px; border-radius: 50%; display: grid; place-items: center; background: conic-gradient(var(--sage) var(--progress), rgba(255,255,255,.52) 0); position: relative; }
.progress-ring::after { content: ""; position: absolute; inset: 11px; border-radius: 50%; background: #eef0e9; }
.progress-ring span { position: relative; z-index: 1; font: 800 24px Manrope, sans-serif; }
.hero-progress small { color: #69716b; }
.stats-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin: 18px 0; }
.stat-card, .report-stats article { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 20px; }
.stat-card > span, .report-stats span, .insight-card > span, .chart-heading span { color: var(--muted); font-size: 12px; font-weight: 600; }
.stat-card strong, .report-stats strong { display: block; margin: 9px 0 3px; font: 750 29px Manrope, sans-serif; letter-spacing: -.04em; }
.stat-card small, .report-stats small { color: #a0a29e; }
.dashboard-grid { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(340px, .9fr); gap: 18px; }
.panel, .chart-card, .insight-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); }
.panel { padding: 22px; }
.panel-header, .section-heading-row, .chart-heading, .modal-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; }
.panel-header h3, .chart-heading h3 { margin: 5px 0 0; font: 700 20px Manrope, sans-serif; letter-spacing: -.025em; }
.section-kicker { margin: 0; }
.habit-list, .english-preview { display: grid; gap: 9px; margin-top: 18px; }
.habit-row, .habit-library-card { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 13px; padding: 13px; border: 1px solid var(--line); border-radius: 15px; background: #fff; }
.symbol { flex: 0 0 auto; width: 39px; height: 39px; display: grid; place-items: center; border-radius: 12px; font: 800 18px Manrope, sans-serif; }
.symbol.plus { background: var(--sage-soft); color: #637a6b; }
.symbol.minus { background: var(--peach-soft); color: #9b6c55; }
.symbol.equal { background: var(--lavender-soft); color: #756e83; }
.habit-copy { min-width: 0; }
.habit-copy strong { display: block; font-size: 14px; line-height: 1.35; }
.habit-copy small { display: block; color: var(--muted); font-size: 11px; margin-top: 4px; }
.status-actions { display: flex; gap: 6px; }
.status-button { min-width: 34px; height: 34px; border-radius: 10px; background: var(--surface-2); color: #92958f; }
.status-button.success.active { background: var(--sage-soft); color: #5f7667; }
.status-button.failed.active { background: var(--danger-soft); color: var(--danger); }
.status-button:hover { filter: brightness(.98); }
.panel-footer-button { width: 100%; background: transparent; color: var(--muted); border-top: 1px solid var(--line); margin-top: 14px; padding: 17px 8px 3px; }
.preview-sentence { padding: 13px 14px; background: var(--surface-2); border-radius: 13px; }
.preview-sentence strong { display: block; font-size: 13px; line-height: 1.45; }
.preview-sentence span { display: block; color: var(--muted); font-size: 11px; margin-top: 5px; }
.english-preview + .primary-button { margin-top: 16px; }

/* Library */
.section-heading-row { align-items: end; margin-bottom: 22px; }
.section-heading-row h2 { margin: 6px 0 7px; font: 750 clamp(28px, 4vw, 38px)/1.1 Manrope, sans-serif; letter-spacing: -.04em; }
.section-heading-row p:not(.section-kicker) { margin: 0; color: var(--muted); }
.legend-card { display: grid; grid-template-columns: repeat(3, 1fr); gap: 22px; padding: 18px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); }
.filter-row { display: flex; flex-wrap: wrap; gap: 8px; margin: 18px 0; }
.filter-chip { padding: 9px 14px; border-radius: 999px; background: transparent; color: var(--muted); border: 1px solid var(--line); }
.filter-chip.active { background: var(--ink); color: white; border-color: var(--ink); }
.habit-library { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 12px; }
.habit-library-card { padding: 15px; }
.library-actions { display: flex; align-items: center; gap: 7px; }
.archive-button { width: 34px; height: 34px; border: 0; border-radius: 10px; background: var(--surface-2); color: var(--muted); cursor: pointer; font-size: 16px; }
.empty-state { padding: 28px; border: 1px dashed #d7d2ca; border-radius: 16px; color: var(--muted); text-align: center; background: rgba(255,255,255,.45); }

/* English */
.inline-actions { display: flex; gap: 9px; }
.english-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 24px; padding: 18px 20px; background: var(--surface); border: 1px solid var(--line); border-radius: 17px; margin-bottom: 14px; }
.english-toolbar > div { min-width: min(100%, 340px); color: var(--muted); font-size: 13px; }
.linear-progress { height: 7px; background: #ece9e2; border-radius: 999px; overflow: hidden; margin-top: 9px; }
.linear-progress span { display: block; height: 100%; width: 0; border-radius: inherit; background: var(--sage); transition: width .25s ease; }
.sentence-list { display: grid; gap: 10px; }
.sentence-card { display: grid; grid-template-columns: 45px minmax(0,1fr) auto; gap: 15px; align-items: center; padding: 17px; border: 1px solid var(--line); border-radius: 17px; background: var(--surface); }
.sentence-number { color: #a1a49f; font: 700 12px Manrope, sans-serif; }
.sentence-copy strong { display: block; line-height: 1.45; }
.translation { margin: 6px 0 0; color: var(--muted); font-size: 13px; line-height: 1.5; }
.vocabulary { margin-top: 6px; color: var(--sage); font-size: 11px; }
.sentence-card.test-mode .translation.hidden-translation { display: inline-block; color: transparent; background: #e9e6df; border-radius: 6px; user-select: none; cursor: pointer; }
.sentence-card.test-mode .translation.hidden-translation::after { content: "Klik untuk melihat arti"; color: #8d908b; padding: 0 4px; }
.memory-button { border-radius: 12px; padding: 10px 13px; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.memory-button.memorized { background: var(--sage-soft); color: #607467; }

/* Reports */
.period-switch { display: flex; background: var(--surface); border: 1px solid var(--line); padding: 4px; border-radius: 13px; }
.period-switch button { border-radius: 9px; padding: 9px 13px; color: var(--muted); background: transparent; }
.period-switch button.active { background: var(--ink); color: white; }
.report-stats { display: grid; grid-template-columns: repeat(3,1fr); gap: 14px; }
.chart-card { padding: 22px; margin-top: 14px; }
.chart-heading { align-items: center; }
.chart-heading strong { font: 750 28px Manrope, sans-serif; }
.report-chart { display: flex; align-items: end; gap: 10px; min-height: 230px; overflow-x: auto; padding: 25px 3px 4px; scrollbar-width: thin; }
.chart-day { flex: 1 0 32px; min-width: 32px; display: grid; gap: 8px; justify-items: center; }
.chart-track { width: 100%; height: 170px; border-radius: 10px; background: var(--surface-2); display: flex; align-items: end; padding: 4px; }
.chart-fill { width: 100%; min-height: 3px; border-radius: 7px; background: linear-gradient(180deg, #8ea094, #718679); transition: height .3s ease; }
.chart-day small { color: var(--muted); font-size: 10px; white-space: nowrap; }
.insight-grid { display: grid; grid-template-columns: repeat(2,1fr); gap: 14px; margin-top: 14px; }
.insight-card { padding: 22px; }
.insight-card h3 { margin: 10px 0 8px; font: 700 20px/1.25 Manrope, sans-serif; }
.insight-card p { margin: 0; color: var(--muted); line-height: 1.55; }

/* Modal, toast, loading */
.modal { width: min(92vw, 510px); border: 0; padding: 0; border-radius: 24px; background: var(--surface); color: var(--ink); box-shadow: 0 35px 90px rgba(30,30,28,.2); }
.modal::backdrop { background: rgba(40,40,38,.36); backdrop-filter: blur(5px); }
.modal form { padding: 25px; display: grid; gap: 19px; }
.modal-header h3 { margin: 5px 0 0; font: 750 24px Manrope, sans-serif; }
.icon-button { border: 0; width: 35px; height: 35px; border-radius: 10px; background: var(--surface-2); cursor: pointer; }
.modal fieldset { border: 0; padding: 0; margin: 0; }
.modal legend { margin-bottom: 10px; color: #555b56; font-size: 13px; font-weight: 700; }
.type-options { display: grid; gap: 8px; }
.type-options label { grid-template-columns: auto auto minmax(0,1fr); align-items: center; gap: 11px; padding: 10px; border: 1px solid var(--line); border-radius: 14px; cursor: pointer; }
.type-options label:has(input:checked) { border-color: var(--sage); background: #fbfcfa; }
.type-options input { accent-color: var(--sage); }
.type-options strong, .type-options small { display: block; }
.type-options small { color: var(--muted); margin-top: 2px; font-weight: 400; }
.modal-actions { display: flex; justify-content: flex-end; gap: 9px; }
.toast { position: fixed; left: 50%; bottom: 25px; transform: translate(-50%, 20px); opacity: 0; pointer-events: none; z-index: 100; background: var(--ink); color: white; border-radius: 12px; padding: 11px 16px; font-size: 13px; transition: .2s ease; }
.toast.show { opacity: 1; transform: translate(-50%,0); }
.loading-screen { position: fixed; inset: 0; background: var(--bg); z-index: 200; display: grid; place-content: center; justify-items: center; gap: 13px; transition: opacity .25s ease; }
.loading-screen p { color: var(--muted); font-size: 13px; }
.loading-screen.done { opacity: 0; pointer-events: none; }
.mobile-nav { display: none; }

@media (max-width: 1050px) {
  :root { --sidebar: 218px; }
  .dashboard-grid { grid-template-columns: 1fr; }
  .habit-library { grid-template-columns: 1fr; }
  .auth-layout { gap: 45px; }
}

@media (max-width: 820px) {
  .auth-screen { padding: 22px 20px 40px; }
  .auth-layout { display: block; min-height: auto; }
  .auth-intro { padding: 70px 0 35px; }
  .auth-intro h1 { font-size: clamp(44px, 13vw, 68px); }
  .sidebar { display: none; }
  .main-content { margin-left: 0; padding: 20px 18px 100px; }
  .profile-copy { display: none; }
  .mobile-nav { position: fixed; display: grid; grid-template-columns: repeat(4,1fr); left: 12px; right: 12px; bottom: calc(10px + env(safe-area-inset-bottom)); z-index: 50; padding: 5px; border: 1px solid rgba(225,220,211,.9); background: rgba(255,253,249,.9); backdrop-filter: blur(18px); border-radius: 17px; box-shadow: 0 15px 40px rgba(40,40,38,.13); }
  .mobile-nav-item { border: 0; background: transparent; color: var(--muted); border-radius: 12px; padding: 10px 5px; font-size: 11px; font-weight: 700; }
  .mobile-nav-item.active { background: var(--sage-soft); color: var(--ink); }
  .legend-card { grid-template-columns: 1fr; }
  .report-stats { grid-template-columns: 1fr 1fr; }
  .report-stats article:first-child { grid-column: 1/-1; }
}

@media (max-width: 620px) {
  .topbar { margin-bottom: 24px; }
  .topbar h1 { font-size: 26px; }
  .ghost-button#installButton { display: none !important; }
  .hero-card { grid-template-columns: 1fr; padding: 26px 22px; }
  .hero-copy h2 { font-size: 34px; }
  .hero-progress { grid-template-columns: auto 1fr; justify-items: start; justify-self: start; }
  .progress-ring { width: 86px; height: 86px; }
  .progress-ring span { font-size: 19px; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .stat-card:last-child { grid-column: 1/-1; }
  .section-heading-row { align-items: flex-start; flex-direction: column; }
  .section-heading-row > .primary-button, .section-heading-row > .inline-actions { width: 100%; }
  .inline-actions { display: grid; grid-template-columns: 1fr 1fr; }
  .english-toolbar { align-items: stretch; flex-direction: column; }
  .sentence-card { grid-template-columns: 34px minmax(0,1fr); }
  .memory-button { grid-column: 2; justify-self: start; }
  .habit-row, .habit-library-card { grid-template-columns: auto minmax(0,1fr); }
  .status-actions, .library-actions { grid-column: 2; justify-self: start; margin-top: 3px; }
  .report-stats, .insight-grid { grid-template-columns: 1fr; }
  .report-stats article:first-child { grid-column: auto; }
  .chart-card { padding: 18px 13px; }
  .auth-principles { gap: 10px; }
}
