:root {
  color-scheme: dark;
  --bg: #191a1d;
  --surface: #222327;
  --cell: #222327;
  --border: #34353a;
  --subtle-border: #303136;
  --text: #f3f1ef;
  --muted: #a4a4ab;
  --soft: #bbb9bf;
  --accent: #ff8069;
  --habit-color: var(--accent);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
  background: var(--bg);
  color: var(--text);
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-width: 280px; }
h1, h2, p { margin: 0; }
button, input, textarea { font: inherit; }
button { color: inherit; cursor: pointer; -webkit-tap-highlight-color: #ff80694d; }
button:disabled, textarea:disabled { opacity: .5; cursor: default; }
button:focus-visible, a:focus-visible, textarea:focus-visible, input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.icon-library { position: absolute; width: 0; height: 0; overflow: hidden; }
.icon {
  width: 20px;
  height: 20px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.65;
  stroke-linejoin: round;
  stroke-linecap: round;
  pointer-events: none;
}

.site-header { border-bottom: 1px solid var(--subtle-border); background: #1d1e21; }
.header-inner {
  max-width: 1376px;
  min-height: 68px;
  margin: 0 auto;
  padding: 0 42px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  text-decoration: none;
  font-size: 24px;
  font-weight: 760;
  letter-spacing: -.08em;
}
.brand-icon {
  display: grid;
  place-items: center;
  width: 33px;
  height: 33px;
  border-radius: 10px;
  color: #271d1b;
  background: var(--accent);
}
.brand-icon .icon { width: 22px; height: 22px; stroke-width: 2.75; }
.brand-period { color: var(--accent); margin-left: 1px; }
.storage-label { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: .8125rem; }
.storage-label .icon { width: 16px; height: 16px; }
.storage-label[data-error] { color: #ffad9e; }
.account { display: flex; align-items: center; gap: 12px; min-width: 0; }
.account-email { color: var(--soft); font-size: .875rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account .button { flex: none; min-height: 34px; }
.account-error { color: #ffad9e; font-size: .875rem; margin-bottom: 12px; }

.auth-page { padding: clamp(24px, 10vh, 108px) 16px 32px; }
.auth-card {
  width: min(100%, 440px);
  margin: 0 auto;
  padding: clamp(20px, 5vw, 36px);
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface);
}
.auth-icon {
  width: 43px;
  height: 43px;
  display: grid;
  place-items: center;
  margin-bottom: 16px;
  border-radius: 11px;
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 15%, var(--bg));
}
.auth-card h1 { font-size: clamp(1.55rem, 3.8vw, 1.9rem); letter-spacing: -.035em; }
.auth-description { margin-top: 10px; color: var(--soft); font-size: .925rem; line-height: 1.5; overflow-wrap: anywhere; }
.auth-description[data-error] { color: #ffad9e; }
.auth-form { margin-top: 19px; display: grid; gap: 8px; }
.auth-form label { color: var(--soft); font-size: .875rem; }
.auth-form input {
  padding: 11px 12px;
  width: 100%;
  min-width: 0;
  border: 1px solid #44454b;
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
}
.auth-card .primary-button { min-height: 43px; margin-top: 8px; }
.auth-secondary { width: 100%; margin-top: 9px; }

.calendar-message {
  display: flex;
  align-items: center;
  gap: 12px 20px;
  justify-content: space-between;
  flex-wrap: wrap;
  margin-bottom: 12px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
}
.calendar-message h2 { font-size: .95rem; }
.calendar-message p { margin-top: 4px; font-size: .85rem; color: var(--soft); }
.calendar-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.calendar-actions .button { min-height: 32px; font-size: .8125rem; }
.save-bar { display: flex; align-items: center; justify-content: space-between; gap: 8px 12px; flex-wrap: wrap; margin-bottom: 12px; }

.workspace {
  max-width: 1376px;
  margin: 0 auto;
  padding: 36px 42px 44px;
  display: grid;
  grid-template-columns: minmax(185px, 232px) minmax(0, 1fr);
  align-items: start;
  gap: 34px;
}
.sidebar { padding-top: 20px; min-width: 0; }
.sidebar-heading { padding: 0 10px; margin-bottom: 13px; }
.sidebar-heading h2 {
  color: var(--soft);
  font-size: .875rem;
  font-weight: 660;
}
.habit-list { list-style: none; padding: 0; margin: 0 0 12px; display: grid; gap: 5px; }
.habit-item {
  display: flex;
  align-items: center;
  min-width: 0;
  border: 1px solid transparent;
  border-radius: 10px;
}
.habit-item[data-active] {
  border-color: color-mix(in srgb, var(--item-color) 25%, var(--border));
  background: color-mix(in srgb, var(--item-color) 10%, var(--bg));
}
.habit-item:hover:not([data-active]) { background: #25262a; }
.habit-button, .edit-habit {
  display: flex;
  align-items: center;
  min-height: 46px;
  border: 0;
  background: transparent;
}
.habit-button {
  flex: 1;
  gap: 11px;
  min-width: 0;
  padding: 0 11px;
  text-align: left;
  border-radius: 9px;
  color: #dbd9dd;
  font-size: .9375rem;
  font-weight: 550;
}
.habit-button[aria-pressed="true"] { color: var(--text); font-weight: 665; }
.habit-symbol {
  width: 25px;
  height: 25px;
  display: grid;
  place-items: center;
  border-radius: 7px;
  flex: none;
  background: color-mix(in srgb, var(--item-color) 17%, transparent);
  color: var(--item-color);
}
.habit-symbol .icon { width: 16px; height: 16px; stroke-width: 2; }
.habit-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.edit-habit { justify-content: center; width: 35px; border-radius: 9px; color: var(--muted); margin-right: 3px; }
.edit-habit:hover { color: var(--text); background: #ffffff10; }
.edit-habit .icon { width: 17px; height: 17px; }

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 40px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #28292e;
  color: var(--text);
  padding: 0 13px;
  font-size: .875rem;
  font-weight: 620;
}
.button:hover:not(:disabled) { background: #313237; border-color: #494a50; }
.button.add-habit {
  width: 100%;
  justify-content: flex-start;
  min-height: 45px;
  padding-left: 11px;
  color: var(--soft);
  background: transparent;
  border-style: dashed;
  border-color: #484950;
}
.add-habit .icon { width: 17px; height: 17px; }
.summary {
  margin-top: 30px;
  padding: 17px 15px 15px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #202125;
}
.summary h2 { display: flex; align-items: center; gap: 7px; font-size: .875rem; font-weight: 620; color: var(--soft); }
.summary h2 .icon { width: 17px; height: 17px; color: var(--habit-color); }
.summary-count { display: flex; align-items: baseline; gap: 4px; margin-top: 12px; color: var(--muted); font-size: .875rem; font-variant-numeric: tabular-nums; }
.summary-count strong { font-size: 2.125rem; line-height: 1.12; color: var(--text); font-weight: 710; letter-spacing: -.05em; }
.summary progress {
  display: block;
  width: 100%;
  height: 5px;
  margin: 13px 0 10px;
  border: 0;
  border-radius: 9px;
  overflow: hidden;
  appearance: none;
  background: #37383e;
  accent-color: var(--habit-color);
}
.summary progress::-webkit-progress-bar { background: #37383e; }
.summary progress::-webkit-progress-value { background: var(--habit-color); border-radius: 9px; }
.summary progress::-moz-progress-bar { background: var(--habit-color); border-radius: 9px; }
.summary-caption { color: var(--muted); font-size: .8125rem; }

.workspace-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 14px;
  margin-bottom: 23px;
}
.current-habit {
  color: var(--soft);
  display: flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 5px;
  font-size: .875rem;
  font-weight: 570;
  overflow-wrap: anywhere;
}
.habit-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--habit-color); flex: none; }
.workspace-heading h1 {
  font-size: clamp(2.15rem, 3.8vw, 3.25rem);
  line-height: 1.05;
  letter-spacing: -.055em;
  font-weight: 740;
}
.mode-switch {
  display: inline-flex;
  align-items: stretch;
  gap: 3px;
  padding: 3px;
  background: #202125;
  border: 1px solid var(--border);
  border-radius: 10px;
}
.mode-switch button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 35px;
  padding: 0 12px;
  border: 1px solid transparent;
  border-radius: 7px;
  background: transparent;
  color: var(--soft);
  font-size: .875rem;
  font-weight: 610;
  white-space: nowrap;
}
.mode-switch button:hover { color: var(--text); }
.mode-switch button[aria-pressed="true"] {
  background: #333238;
  border-color: #444149;
  color: var(--text);
}
#draw-mode[aria-pressed="true"] .icon { color: var(--accent); }
.mode-switch .icon { width: 16px; height: 16px; }

.calendar-card, .note-card { border: 1px solid var(--border); border-radius: 15px; background: var(--surface); }
.calendar-card { overflow: hidden; }
.calendar-header {
  min-height: 68px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 9px;
  padding: 12px 19px;
  border-bottom: 1px solid var(--border);
}
.calendar-header h2 { font-size: clamp(1.15rem, 2.6vw, 1.5rem); font-weight: 680; letter-spacing: -.035em; }
.month-nav { display: flex; align-items: center; gap: 8px; }
.month-arrows { display: inline-flex; gap: 4px; }
.icon-button { padding: 0; width: 39px; }
.icon-button .icon { width: 18px; height: 18px; }
.today { color: var(--soft); white-space: nowrap; }

.drawing-toolbar {
  min-height: 59px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 9px 16px;
  padding: 7px 19px;
  border-bottom: 1px solid var(--border);
  background: #24252a;
}
.drawing-tools, .palette { display: inline-flex; align-items: center; gap: 2px; }
.drawing-tools { padding-right: 13px; border-right: 1px solid #414248; }
.tool-button {
  width: 38px;
  height: 38px;
  padding: 0;
  display: grid;
  place-items: center;
  border: 1px solid transparent;
  border-radius: 8px;
  color: var(--soft);
  background: transparent;
}
.tool-button:hover { background: #333439; color: var(--text); }
.tool-button[aria-pressed="true"] { color: var(--accent); border-color: #6a4542; background: #392d30; }
.tool-button .icon { width: 19px; height: 19px; }
.swatch {
  display: grid;
  padding: 0;
  place-items: center;
  width: 30px;
  height: 34px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #262024;
}
.swatch span {
  width: 19px;
  height: 19px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--swatch-color);
}
.swatch .icon { visibility: hidden; width: 12px; height: 12px; stroke-width: 2.8; }
.swatch:hover { background: #ffffff0f; }
.swatch[aria-pressed="true"] .icon { visibility: visible; }
.swatch[aria-pressed="true"] span { outline: 1px solid var(--swatch-color); outline-offset: 2px; }
.width-control { display: flex; align-items: center; gap: 9px; color: var(--soft); font-size: .8125rem; margin-left: auto; }
.width-control input { margin: 0; width: 93px; height: 28px; accent-color: var(--accent); cursor: pointer; }

.weekdays, .days { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.weekdays { border-bottom: 1px solid var(--border); background: #24252a; }
.weekdays span {
  display: flex;
  align-items: center;
  min-height: 39px;
  padding: 0 13px;
  color: var(--soft);
  font-size: .875rem;
  font-weight: 620;
}
.weekdays span:nth-child(n + 6) { color: #cfaca8; }
.days { gap: 1px; background: var(--border); }
.day, .day-spacer {
  min-width: 0;
  height: clamp(62px, 9.1vh, 85px);
  background: var(--cell);
}
.day-spacer {
  background: repeating-linear-gradient(135deg, #1d1e22 0 6px, #212226 6px 7px);
}
.day {
  position: relative;
  padding: 0;
  isolation: isolate;
  border: 0;
  border-radius: 0;
  color: var(--text);
}
.day:nth-child(7n), .day:nth-child(7n - 1) { --cell: #24252a; }
.day:hover:not(:disabled) { background: #2a2b31; }
.day:focus-visible { z-index: 1; outline-offset: -3px; }
.day[data-selected] {
  background: color-mix(in srgb, var(--habit-color) 9%, var(--cell));
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--habit-color) 69%, var(--border));
}
.day[data-selected]:hover:not(:disabled) { background: color-mix(in srgb, var(--habit-color) 14%, var(--cell)); }
.day-number {
  position: absolute;
  z-index: 1;
  display: grid;
  place-items: center;
  min-width: 24px;
  height: 24px;
  top: 7px;
  left: 8px;
  border-radius: 7px;
  color: #e8e4e6;
  font-size: .875rem;
  font-weight: 590;
  font-variant-numeric: tabular-nums;
  pointer-events: none;
}
.day[aria-current="date"] .day-number { color: #281e20; background: var(--habit-color); font-weight: 740; }
.ink { position: absolute; width: 100%; height: 100%; inset: 0; pointer-events: none; }
.note-indicator { display: none; position: absolute; right: 7px; bottom: 6px; color: var(--habit-color); pointer-events: none; }
.note-indicator .icon { display: block; width: 15px; height: 15px; }
.day[data-note] .note-indicator { display: block; }
.days[data-drawing] .day[data-selected] { cursor: crosshair; touch-action: none; user-select: none; }

.note-card {
  display: grid;
  grid-template-columns: minmax(154px, .34fr) minmax(0, 1fr);
  align-items: start;
  gap: 13px;
  margin-top: 14px;
  padding: 16px 19px;
}
.note-heading { display: flex; gap: 10px; align-items: center; }
.note-icon {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  flex: none;
  border-radius: 9px;
  color: var(--habit-color);
  background: color-mix(in srgb, var(--habit-color) 13%, var(--surface));
}
.note-icon .icon { width: 19px; height: 19px; }
.note-heading h2 { font-size: .9375rem; font-weight: 660; }
.note-heading p { color: var(--muted); font-size: .8125rem; margin-top: 1px; }
.note-card textarea {
  width: 100%;
  min-height: 73px;
  max-height: 340px;
  padding: 10px 12px;
  resize: vertical;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: #1d1e22;
  color: var(--text);
  line-height: 1.45;
}
.note-card textarea::placeholder { color: var(--muted); }

dialog {
  width: min(400px, calc(100% - 28px));
  padding: 20px;
  border: 1px solid #42434a;
  border-radius: 14px;
  color: var(--text);
  background: var(--surface);
  box-shadow: 0 16px 80px #0007;
}
dialog::backdrop { background: #090a0bbe; }
.dialog-heading { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.dialog-heading h2 { font-size: 1.25rem; letter-spacing: -.025em; }
.dialog-label { display: block; color: var(--soft); font-size: .875rem; margin: 13px 0 6px; }
#habit-name {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid #44454b;
  border-radius: 8px;
  background: #191a1d;
  color: var(--text);
}
#habit-colors .swatch { width: 38px; height: 40px; }
.primary-button { width: 100%; margin-top: 15px; background: var(--accent); color: #261b1a; border-color: var(--accent); }
.primary-button:hover:not(:disabled) { background: #ff9a87; border-color: #ff9a87; }
.no-script { max-width: 45ch; margin: 0 auto 16px; padding: 15px; color: var(--soft); }

@media (max-width: 980px) {
  .header-inner { padding-inline: 25px; }
  .workspace { grid-template-columns: minmax(164px, 190px) minmax(0, 1fr); gap: 21px; padding: 27px 25px 35px; }
  .drawing-toolbar { gap: 8px 10px; }
  .drawing-tools { padding-right: 8px; }
  .width-control input { width: 67px; }
}

@media (max-width: 760px) {
  .header-inner { min-height: 59px; padding-inline: 16px; }
  .brand { font-size: 23px; }
  .brand-icon { width: 31px; height: 31px; }
  .workspace { grid-template-columns: minmax(0, 1fr); gap: 19px; padding: 16px 16px 28px; }
  .sidebar { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 8px; padding: 0; }
  .sidebar-heading { padding: 0; margin: 0; }
  .habit-list { grid-column: 1 / -1; grid-row: 2; display: flex; overflow: auto; padding: 3px 3px 6px; margin: 0 -3px; gap: 5px; }
  .habit-item { flex: 0 0 auto; max-width: 80%; border-color: var(--subtle-border); background: var(--surface); }
  .habit-button { padding-inline: 8px; min-height: 42px; gap: 6px; font-size: .875rem; }
  .habit-symbol { width: 22px; height: 22px; }
  .edit-habit { min-height: 42px; width: 27px; margin-right: 1px; }
  .edit-habit .icon { width: 15px; height: 15px; }
  .button.add-habit { justify-content: center; min-height: 40px; padding-inline: 9px; }
  .summary { display: none; }
  .workspace-heading { margin-bottom: 14px; gap: 12px 9px; align-items: end; }
  .workspace-heading h1 { font-size: 2.15rem; }
  .mode-switch button { padding: 0 8px; min-height: 36px; gap: 5px; }
  .calendar-header { min-height: 59px; padding: 8px 10px; }
  .calendar-header h2 { font-size: 1.15rem; }
  .calendar-card, .note-card { border-radius: 11px; }
  .drawing-toolbar { padding: 5px 8px; min-height: 50px; gap: 3px 8px; }
  .drawing-tools { padding-right: 5px; gap: 0; }
  .tool-button { width: 35px; }
  .swatch { width: 29px; }
  .weekdays span { padding: 0; justify-content: center; min-height: 33px; }
  .day, .day-spacer { height: clamp(48px, 13vw, 72px); }
  .day-number { top: 4px; left: 4px; }
  .note-indicator { right: 4px; bottom: 4px; }
  .note-card { margin-top: 11px; padding: 11px; }
}

@media (max-width: 510px) {
  .calendar-header { gap: 4px; }
  .month-nav { gap: 4px; }
  .month-arrows { gap: 3px; }
  .month-nav .icon-button { min-width: 38px; }
  .today { padding-inline: 8px; }
  .width-control { width: 100%; justify-content: space-between; border-top: 1px solid var(--border); }
  .width-control input { width: 94px; }
  .note-card { grid-template-columns: 1fr; gap: 8px; }
}

@media (max-width: 360px) {
  .header-inner { padding-inline: 11px; }
  .workspace { padding-inline: 10px; }
  .workspace-heading h1 { font-size: 1.9rem; }
  .drawing-toolbar { gap: 3px 5px; }
  .drawing-tools { padding-right: 3px; }
  .tool-button { width: 30px; }
  .drawing-toolbar .swatch { width: 26px; }
  .calendar-header h2 { font-size: 1.05rem; }
}
