*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #e8e8ed;
  --bg-card: #f5f5f7;
  --bg-card-hover: #ebebf0;
  --bg-inset: #e8e8ed;
  --border: rgba(0,0,0,0.08);
  --border-light: rgba(0,0,0,0.05);
  --text: #1c1c1e;
  --text-secondary: #6c6c70;
  --text-tertiary: #aeaeb2;
  --accent: #34c759;
  --accent-soft: rgba(52,199,89,0.12);
  --green: #34c759;
  --green-soft: rgba(52,199,89,0.12);
  --yellow: #ff9f0a;
  --yellow-soft: rgba(255,159,10,0.12);
  --red: #ff3b30;
  --red-soft: rgba(255,59,48,0.12);
  --blue: #007aff;
  --purple: #af52de;
  --radius: 18px;
  --radius-sm: 12px;
  --radius-xs: 8px;
}

html, body { height: 100%; background: var(--bg); color: var(--text); font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', sans-serif; overflow: hidden; user-select: none; -webkit-font-smoothing: antialiased; }

.app { display: flex; flex-direction: column; height: 100vh; padding: 10px; gap: 8px; }

/* HEADER */
.header { background: var(--bg-card); border-radius: var(--radius); padding: 12px 20px; display: flex; justify-content: space-between; align-items: center; flex-shrink: 0; border: 1px solid var(--border); box-shadow: 0 1px 4px rgba(0,0,0,0.06); }
.clock { font-size: 44px; font-weight: 200; letter-spacing: -2px; color: var(--text); line-height: 1; font-variant-numeric: tabular-nums; }
.hdr-center { text-align: center; }
.dayname { font-size: 10px; text-transform: uppercase; letter-spacing: 2px; color: var(--accent); font-weight: 700; }
.datefull { font-size: 12px; color: var(--text-secondary); margin-top: 3px; }
.weather { text-align: right; }
.weather-temp { font-size: 24px; font-weight: 300; display: flex; align-items: center; gap: 5px; justify-content: flex-end; color: var(--text); }
.weather-desc { font-size: 11px; color: var(--text-secondary); margin-top: 2px; }
.weather-range { font-size: 10px; color: var(--text-tertiary); margin-top: 1px; }

/* LAYOUT */
.main { display: flex; flex-direction: column; gap: 8px; flex: 1; min-height: 0; }
.row3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; flex: 1.3; min-height: 0; }
.row2 { display: grid; grid-template-columns: 5fr 7fr; gap: 8px; flex: 1; min-height: 0; }

/* CARDS */
.card { background: var(--bg-card); border-radius: var(--radius); padding: 14px 16px; border: 1px solid var(--border); display: flex; flex-direction: column; overflow: hidden; min-height: 0; box-shadow: 0 1px 4px rgba(0,0,0,0.05); }
.stitle { font-size: 9px; letter-spacing: 1.5px; text-transform: uppercase; color: var(--text-tertiary); font-weight: 700; margin-bottom: 11px; flex-shrink: 0; }

/* CALENDAR */
.events-list { display: flex; flex-direction: column; gap: 6px; flex: 1; overflow: hidden; }
.event { display: flex; gap: 8px; align-items: stretch; background: var(--bg-inset); border-radius: var(--radius-xs); padding: 7px 9px; flex-shrink: 0; }
.etime { font-size: 10px; color: var(--text-tertiary); width: 32px; flex-shrink: 0; padding-top: 1px; font-variant-numeric: tabular-nums; }
.ebar { width: 3px; border-radius: 2px; flex-shrink: 0; }
.event-body { padding-left: 2px; }
.etitle { font-size: 12px; color: var(--text); font-weight: 500; }
.esub { font-size: 10px; color: var(--text-secondary); margin-top: 1px; }
.legend { display: flex; gap: 6px; margin-top: 9px; padding-top: 9px; border-top: 1px solid var(--border-light); flex-shrink: 0; }
.cal-filter { display: flex; align-items: center; gap: 4px; padding: 3px 10px; border-radius: 20px; font-size: 10px; font-weight: 600; color: var(--text-tertiary); cursor: pointer; border: 1.5px solid transparent; transition: all .2s; background: var(--bg-inset); }
.cal-filter.active { border-color: var(--accent); color: var(--text); background: var(--accent-soft); }
.cal-filter .ldot { width: 6px; height: 6px; border-radius: 50%; display: inline-block; flex-shrink: 0; }

/* CIRCLES */
.circles-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; flex: 1; align-content: start; }
.circle-item { display: flex; flex-direction: column; align-items: center; gap: 2px; cursor: pointer; border-radius: var(--radius-xs); padding: 6px 4px; background: var(--bg-inset); transition: background .2s, transform .1s; }
.circle-item:active { transform: scale(0.95); }
.circle-name { font-size: 10px; color: var(--text-secondary); text-align: center; font-weight: 500; }
.circle-time { font-size: 9px; text-align: center; font-weight: 700; }

/* HABITS */
.habits-list { display: flex; flex-direction: column; flex: 1; overflow: hidden; gap: 1px; }
.habit { display: flex; align-items: center; gap: 7px; padding: 5px 7px; border-radius: var(--radius-xs); cursor: pointer; transition: background .15s; }
.habit:hover { background: var(--bg-inset); }
.habit-icon { font-size: 14px; width: 18px; text-align: center; flex-shrink: 0; }
.habit-name { font-size: 11px; color: var(--text-secondary); font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.habit.done .habit-name { color: var(--text-tertiary); text-decoration: line-through; }
.habit-dots { display: flex; gap: 3px; margin-top: 2px; }
.hdot { width: 5px; height: 5px; border-radius: 50%; flex-shrink: 0; }
.habit-streak { font-size: 9px; color: var(--text-tertiary); flex-shrink: 0; }
.hcheck { width: 17px; height: 17px; border-radius: 50%; border: 1.5px solid var(--text-tertiary); display: flex; align-items: center; justify-content: center; transition: all .2s; flex-shrink: 0; margin-left: auto; }
.habit.done .hcheck { background: var(--accent); border-color: var(--accent); }
.hcheck-in { width: 6px; height: 4px; border-left: 1.5px solid white; border-bottom: 1.5px solid white; transform: rotate(-45deg) translateY(-1px); display: none; }
.habit.done .hcheck-in { display: block; }
.habit-footer { margin-top: 7px; padding-top: 7px; border-top: 1px solid var(--border-light); display: flex; justify-content: space-between; align-items: center; flex-shrink: 0; }

/* SHOPPING */
.shop-list { list-style: none; overflow-y: auto; flex: 1; }
.sitem { display: flex; gap: 9px; align-items: center; padding: 7px 0; border-bottom: 1px solid var(--border-light); cursor: pointer; }
.sitem:last-child { border-bottom: none; }
.scheck { width: 18px; height: 18px; border-radius: 50%; border: 1.5px solid var(--text-tertiary); flex-shrink: 0; display: flex; align-items: center; justify-content: center; transition: all .2s; }
.sitem.done .scheck { background: var(--green); border-color: var(--green); }
.schk-in { width: 6px; height: 4px; border-left: 1.5px solid white; border-bottom: 1.5px solid white; transform: rotate(-45deg) translateY(-1px); display: none; }
.sitem.done .schk-in { display: block; }
.sname { font-size: 13px; color: var(--text); font-weight: 400; transition: all .2s; }
.sitem.done .sname { text-decoration: line-through; color: var(--text-tertiary); }
.add-row { display: flex; align-items: center; gap: 8px; margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--border-light); flex-shrink: 0; }
.add-btn { width: 22px; height: 22px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); font-size: 16px; cursor: pointer; display: flex; align-items: center; justify-content: center; flex-shrink: 0; transition: background .2s; line-height: 1; font-weight: 300; }
.add-btn:hover { background: rgba(52,199,89,0.2); }
.add-input { background: var(--bg-inset); border: 1px solid var(--border); border-radius: var(--radius-xs); color: var(--text); font-size: 12px; padding: 5px 10px; flex: 1; outline: none; display: none; font-family: inherit; }
.add-input:focus { border-color: var(--accent); }
.add-hint { font-size: 11px; color: var(--text-tertiary); }

/* DAILY TEXT */
.dtext { font-size: 13px; line-height: 1.8; color: var(--text-secondary); font-style: italic; font-weight: 400; flex: 1; overflow-y: auto; }
.dverse { font-size: 11px; color: var(--accent); margin-top: 8px; font-weight: 700; flex-shrink: 0; }
.dcomment { font-size: 11px; color: var(--text-tertiary); margin-top: 6px; line-height: 1.65; overflow-y: auto; flex: 1; }
.dread-btn { display: flex; align-items: center; gap: 5px; margin-top: 8px; padding: 5px 10px; background: var(--accent-soft); border: none; border-radius: 20px; color: var(--accent); font-size: 11px; font-weight: 600; cursor: pointer; font-family: inherit; transition: background .2s; flex-shrink: 0; width: fit-content; }
.dread-btn:hover { background: rgba(52,199,89,0.2); }
.dread-btn.playing { background: var(--red-soft); color: var(--red); }

/* FOOTER */
.footer { background: var(--bg-card); border-radius: var(--radius); padding: 8px 16px; display: flex; justify-content: space-between; align-items: center; flex-shrink: 0; border: 1px solid var(--border); box-shadow: 0 1px 4px rgba(0,0,0,0.06); }
.notif { display: flex; align-items: center; gap: 7px; }
.ndot { width: 6px; height: 6px; border-radius: 50%; background: var(--red); flex-shrink: 0; }
.ntext { font-size: 11px; color: var(--text-secondary); }
.settings-btn { width: 28px; height: 28px; border-radius: 50%; background: var(--bg-inset); border: 1px solid var(--border); display: flex; align-items: center; justify-content: center; cursor: pointer; font-size: 14px; transition: background .2s; }
.settings-btn:hover { background: var(--bg-card-hover); }

/* SETTINGS OVERLAY */
.settings-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.3); z-index: 100; display: none; align-items: flex-end; justify-content: center; backdrop-filter: blur(4px); }
.settings-overlay.open { display: flex; }
.settings-panel { background: var(--bg-card); border-radius: 24px 24px 0 0; width: 100%; max-height: 85vh; display: flex; flex-direction: column; border: 1px solid var(--border); border-bottom: none; animation: slideUp .3s ease; box-shadow: 0 -4px 30px rgba(0,0,0,0.1); }
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
.settings-handle { width: 36px; height: 4px; background: var(--text-tertiary); border-radius: 2px; margin: 12px auto 0; flex-shrink: 0; cursor: pointer; }
.settings-header { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px 0; flex-shrink: 0; }
.settings-title { font-size: 18px; font-weight: 600; color: var(--text); }
.settings-close { width: 28px; height: 28px; border-radius: 50%; background: var(--bg-inset); border: none; color: var(--text-secondary); font-size: 14px; cursor: pointer; display: flex; align-items: center; justify-content: center; }

.settings-tabs { display: flex; gap: 6px; padding: 14px 20px 0; flex-shrink: 0; overflow-x: auto; }
.stab { padding: 6px 14px; border-radius: 20px; font-size: 12px; font-weight: 600; cursor: pointer; border: none; background: var(--bg-inset); color: var(--text-secondary); font-family: inherit; transition: all .2s; white-space: nowrap; }
.stab.active { background: var(--accent); color: white; }

.settings-content { flex: 1; overflow-y: auto; padding: 16px 20px 30px; }
.stab-pane { display: none; }
.stab-pane.active { display: block; }

.sset-item { display: flex; align-items: center; gap: 12px; padding: 12px 14px; background: var(--bg-inset); border-radius: var(--radius-sm); margin-bottom: 8px; }
.sset-icon { font-size: 20px; width: 24px; text-align: center; flex-shrink: 0; }
.sset-info { flex: 1; min-width: 0; }
.sset-name { font-size: 13px; color: var(--text); font-weight: 500; }
.sset-sub { font-size: 11px; color: var(--text-tertiary); margin-top: 2px; }
.sset-del { width: 26px; height: 26px; border-radius: 50%; background: var(--red-soft); border: none; color: var(--red); font-size: 13px; cursor: pointer; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }

.sadd-form { background: var(--bg-inset); border-radius: var(--radius-sm); padding: 14px; margin-top: 12px; }
.sadd-title { font-size: 11px; font-weight: 700; color: var(--text-tertiary); margin-bottom: 10px; text-transform: uppercase; letter-spacing: 1px; }
.sadd-row { display: flex; gap: 8px; margin-bottom: 8px; align-items: center; }
.sadd-label { font-size: 11px; color: var(--text-tertiary); width: 60px; flex-shrink: 0; }
.sadd-input { flex: 1; background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-xs); color: var(--text); font-size: 12px; padding: 6px 10px; outline: none; font-family: inherit; }
.sadd-input:focus { border-color: var(--accent); }
.sadd-btn { background: var(--accent); color: white; border: none; border-radius: var(--radius-xs); padding: 8px 16px; font-size: 12px; font-weight: 700; cursor: pointer; font-family: inherit; width: 100%; margin-top: 4px; }

.day-picker { display: flex; gap: 5px; }
.day-btn { width: 28px; height: 28px; border-radius: 50%; border: 1.5px solid var(--border); background: var(--bg-card); color: var(--text-tertiary); font-size: 10px; font-weight: 700; cursor: pointer; transition: all .2s; font-family: inherit; }
.day-btn.active { background: var(--accent); border-color: var(--accent); color: white; }

.danger-btn { background: var(--red-soft); border: 1px solid rgba(255,59,48,0.15); border-radius: var(--radius-sm); padding: 12px 16px; color: var(--red); font-size: 13px; font-weight: 500; cursor: pointer; font-family: inherit; width: 100%; margin-bottom: 8px; text-align: left; }
.ssection { font-size: 11px; color: var(--text-tertiary); font-weight: 700; letter-spacing: 1px; text-transform: uppercase; margin: 16px 0 8px; }

.loading { opacity: .4; font-size: 11px; color: var(--text-secondary); }
@keyframes blink { 0%,100%{opacity:1} 50%{opacity:.3} }
.ndot { animation: blink 2.5s ease-in-out infinite; }
::-webkit-scrollbar { width: 3px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--text-tertiary); border-radius: 2px; }