:root {
  --accent: #3F51B5;
  --bg: #ffffff;
  --text: #1a1a1a;
  --muted: #757575;
  --border: #e0e0e0;
  --danger: #d32f2f;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: -apple-system, system-ui, sans-serif; background: var(--bg); color: var(--text); }
.hidden { display: none !important; }

.login-box { max-width: 360px; margin: 15vh auto; padding: 2rem; text-align: center; }
.login-box h1 { margin-bottom: 1.5rem; }
.login-box .err { color: var(--danger); min-height: 1.2em; margin-bottom: 1rem; }
.primary { display: inline-block; background: var(--accent); color: #fff; border: none; padding: .7rem 1.4rem; border-radius: 8px; text-decoration: none; font-size: 1rem; cursor: pointer; }

header { padding: 1rem; text-align: center; border-bottom: 1px solid var(--border); }
header h1 { margin: 0; font-size: 1.2rem; }

main { padding: 1rem; padding-bottom: 5rem; max-width: 640px; margin: 0 auto; }

#tabbar { position: fixed; bottom: 0; left: 0; right: 0; display: flex; background: #fff; border-top: 1px solid var(--border); }
#tabbar button { flex: 1; background: none; border: none; padding: .6rem 0; font-size: 1.3rem; color: var(--muted); cursor: pointer; }
#tabbar button.active { color: var(--accent); }
#tabbar button span { display: block; font-size: .65rem; margin-top: 2px; }

.fab { position: fixed; right: 1.2rem; bottom: 4.5rem; width: 56px; height: 56px; border-radius: 50%; background: var(--accent); color: #fff; font-size: 1.6rem; border: none; box-shadow: 0 2px 6px rgba(0,0,0,.3); cursor: pointer; }

.habit-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(80px, 1fr)); gap: 1rem; }
.habit-tile { text-align: center; }
.ring-outer { width: 56px; height: 56px; border-radius: 50%; margin: 0 auto; display: flex; align-items: center; justify-content: center; cursor: pointer; }
.ring-inner { width: 48px; height: 48px; border-radius: 50%; opacity: .85; display: flex; align-items: center; justify-content: center; font-size: 20px; }
.habit-tile .count { font-size: .75rem; margin-top: .25rem; }
.habit-tile .name { font-size: .7rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile-actions { display: flex; justify-content: center; gap: .4rem; margin-top: .2rem; }
.tile-actions button { border: none; background: none; cursor: pointer; font-size: .85rem; }

.empty { text-align: center; color: var(--muted); margin-top: 3rem; }
.error-banner { color: var(--danger); text-align: center; padding: 1rem; }

.todo-item { display: flex; align-items: flex-start; padding: .6rem 0; border-bottom: 1px solid var(--border); gap: .6rem; }
.todo-item .todo-title { flex: 1; }
.todo-item.done .todo-title { text-decoration: line-through; color: var(--muted); }
.todo-meta { font-size: .75rem; color: var(--muted); }
.todo-sub { font-size: .75rem; color: var(--muted); }
.checklist { padding-left: 1.8rem; margin: .4rem 0; }
.checklist-item { display: flex; align-items: center; gap: .5rem; padding: .2rem 0; }
.checklist-item.done .checklist-text { text-decoration: line-through; color: var(--muted); }
.checklist-add { display: flex; gap: .4rem; margin-top: .3rem; }
.checklist-add input { flex: 1; }

.verse-box { max-width: 480px; margin: 2rem auto; text-align: center; }
.verse-ref { font-weight: bold; font-size: 1.2rem; }
.verse-text { font-style: italic; margin: 1rem 0; }

.accent-presets, .color-presets { display: flex; flex-wrap: wrap; gap: .7rem; }
.accent-swatch, .color-swatch { width: 40px; height: 40px; border-radius: 50%; border: 2px solid var(--border); cursor: pointer; display: flex; align-items: center; justify-content: center; color: #fff; }
.accent-swatch.selected, .color-swatch.selected { border-color: #000; }

.modal { position: fixed; inset: 0; background: rgba(0,0,0,.5); display: flex; align-items: center; justify-content: center; padding: 1rem; z-index: 10; }
.modal-content { background: #fff; border-radius: 12px; padding: 1.5rem; width: min(480px, 100%); max-height: 85vh; overflow: auto; }
.modal-content label { display: block; margin-top: .8rem; font-size: .85rem; color: var(--muted); }
.modal-content input[type=text], .modal-content input[type=time], .modal-content input[type=date], .modal-content textarea {
  width: 100%; padding: .5rem; border: 1px solid var(--border); border-radius: 6px; font-size: 1rem; margin-top: .2rem;
}
.chip-row { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .4rem; align-items: center; }
.chip { padding: .3rem .6rem; border-radius: 16px; border: 1px solid var(--border); font-size: .8rem; cursor: pointer; background: #fff; }
.chip.selected { background: var(--accent); color: #fff; border-color: var(--accent); }
.chip.removable { display: flex; align-items: center; gap: .3rem; cursor: default; }
.chip.removable button { border: none; background: none; cursor: pointer; }
.stepper { display: flex; align-items: center; gap: .8rem; margin-top: .4rem; }
.stepper button { width: 32px; height: 32px; border-radius: 50%; border: 1px solid var(--border); background: #fff; font-size: 1rem; cursor: pointer; }
.modal-actions { display: flex; justify-content: flex-end; gap: .6rem; margin-top: 1.4rem; }
.danger { background: none; border: 1px solid var(--danger); color: var(--danger); padding: .5rem 1rem; border-radius: 6px; cursor: pointer; }
.err { color: var(--danger); font-size: .85rem; min-height: 1.2em; margin-top: .6rem; }

@media (min-width: 900px) {
  #app-view {
    display: grid;
    grid-template-columns: 220px 1fr;
    grid-template-rows: auto 1fr;
    grid-template-areas:
      "header header"
      "tabbar main";
    min-height: 100vh;
  }

  header { grid-area: header; text-align: left; padding: 1rem 2rem; }

  #tabbar {
    grid-area: tabbar;
    position: static;
    flex-direction: column;
    align-items: stretch;
    border-top: none;
    border-right: 1px solid var(--border);
    padding: 1rem 0;
  }
  #tabbar button {
    flex: none;
    display: flex;
    align-items: center;
    gap: .7rem;
    justify-content: flex-start;
    padding: .7rem 1.5rem;
    font-size: 1.1rem;
    border-left: 3px solid transparent;
  }
  #tabbar button.active { border-left-color: var(--accent); background: rgba(0, 0, 0, .03); }
  #tabbar button span { font-size: .95rem; margin-top: 0; }

  main {
    grid-area: main;
    max-width: 1100px;
    padding: 2rem 3rem;
    margin: 0;
  }

  .habit-grid { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 1.5rem; }

  .fab { bottom: 2rem; }
}

header { display: flex; align-items: center; justify-content: space-between; gap: .8rem; position: relative; }
header h1 { flex: 1; text-align: center; margin: 0; }
.avatar-wrap { position: relative; }
.avatar-btn, .icon-btn { background: none; border: none; cursor: pointer; font-size: 1.3rem; padding: .3rem; border-radius: 50%; display: flex; align-items: center; justify-content: center; }
.avatar-img { width: 32px; height: 32px; border-radius: 50%; object-fit: cover; }
.profile-menu { position: absolute; top: 110%; left: 0; background: #fff; border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 2px 8px rgba(0,0,0,.15); padding: .6rem; min-width: 160px; z-index: 20; }
.profile-name { font-size: .85rem; font-weight: bold; margin-bottom: .5rem; padding: 0 .3rem; }
.profile-menu button { width: 100%; text-align: left; background: none; border: none; padding: .5rem .3rem; cursor: pointer; border-radius: 4px; font-size: .9rem; }
.profile-menu button:hover { background: #f5f5f5; }

.vision-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 1rem; }
.vision-thumb { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 8px; cursor: pointer; background: #eee; display: block; }
.lightbox-content { background: #111; border-radius: 12px; padding: 1rem; max-width: 90vw; max-height: 90vh; display: flex; flex-direction: column; align-items: center; gap: .8rem; position: relative; }
.lightbox-content img { max-width: 100%; max-height: 65vh; object-fit: contain; border-radius: 8px; }
.lightbox-close { position: absolute; top: .5rem; right: .5rem; background: rgba(255,255,255,.15); color: #fff; border: none; border-radius: 50%; width: 32px; height: 32px; cursor: pointer; }
.lightbox-nav { display: flex; align-items: center; gap: 1rem; }
.lightbox-nav button { background: none; border: none; color: #fff; font-size: 1.6rem; cursor: pointer; }
.lightbox-dots { display: flex; gap: 6px; }
.lightbox-dots span { width: 8px; height: 8px; border-radius: 50%; background: rgba(255,255,255,.4); display: inline-block; }
.lightbox-dots span.active { background: #fff; }

.goal-list-header { display: flex; align-items: center; justify-content: center; gap: .8rem; margin-bottom: 1rem; }
.goal-list-header button { background: none; border: none; font-size: 1.4rem; cursor: pointer; }
.goal-section-title { font-weight: bold; font-size: .9rem; margin: 1rem 0 .5rem; }
.goal-tile { display: flex; align-items: center; gap: .6rem; padding: .6rem; border: 1px solid var(--border); border-radius: 8px; margin-bottom: .6rem; }
.goal-tile .goal-text { flex: 1; }
.goal-tile.done .goal-text { text-decoration: line-through; color: var(--muted); }
.goal-tile .goal-range { font-size: .75rem; color: var(--muted); }
#goal-range-fields label { margin-top: .6rem; }

.verse-divider { border: none; border-top: 1px solid var(--border); margin: 2rem 0; }
.quote-text { font-style: italic; text-align: center; }
.quote-text-en { font-style: italic; font-size: .8rem; color: var(--muted); text-align: center; margin-top: .5rem; }
.quote-author { font-weight: bold; text-align: center; margin-top: 1rem; }
