:root {
  --bg: #F4F1EA;
  --bg-elevated: #FFFCF5;
  --bg-panel: #EDE6DA;
  --accent: #C45C26;
  --accent-dim: #A34A1D;
  --sand: #E8DCC8;
  --sand-dim: #D4C4A8;
  --text: #1A1A1A;
  --text-muted: #6B6358;
  --danger: #B33A3A;
  --border: rgba(196, 92, 38, 0.28);
  --radius: 12px;
  --font: "DM Sans", system-ui, sans-serif;
  --font-display: "Fraunces", Georgia, serif;
  --fs-base: 15px;
  --widget-bg: #ffffff;
  --widget-text: #1A1A1A;
  --widget-muted: #5A5A5A;
  --widget-finance: #1B5E20;
}

* { box-sizing: border-box; }
html {
  scrollbar-width: thin;
  scrollbar-color: var(--accent) var(--sand);
}
html::-webkit-scrollbar,
body::-webkit-scrollbar,
*::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
html::-webkit-scrollbar-track,
body::-webkit-scrollbar-track,
*::-webkit-scrollbar-track {
  background: var(--sand);
}
html::-webkit-scrollbar-thumb,
body::-webkit-scrollbar-thumb,
*::-webkit-scrollbar-thumb {
  background: var(--accent);
  border-radius: 3px;
}
html::-webkit-scrollbar-thumb:hover,
body::-webkit-scrollbar-thumb:hover,
*::-webkit-scrollbar-thumb:hover {
  background: var(--accent-dim);
}
html, body {
  margin: 0;
  min-height: 100%;
  font-family: var(--font);
  font-size: var(--fs-base);
  color: var(--text);
  background:
    radial-gradient(ellipse 70% 45% at 8% -5%, rgba(232, 220, 200, 0.9), transparent 55%),
    radial-gradient(ellipse 50% 35% at 95% 5%, rgba(196, 92, 38, 0.08), transparent 50%),
    linear-gradient(165deg, #F7F3EC 0%, var(--bg) 50%, #EDE4D6 100%);
  background-attachment: fixed;
}

.hidden { display: none !important; }

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.login-panel {
  width: min(380px, 100%);
  padding: 32px 28px;
  background: #FFFCF5;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 18px 40px rgba(90, 60, 30, 0.12);
}
.login-brand {
  margin: 0 0 22px;
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: -0.02em;
}
.form-error {
  min-height: 1.2em;
  margin: 10px 0 0;
  color: var(--danger);
  font-size: 0.9rem;
}

.settings-wrap {
  max-width: 1480px;
  margin: 0 auto;
  padding: 20px 24px 48px;
  display: grid;
  grid-template-columns: 168px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}
.settings-nav {
  display: flex;
  flex-direction: column;
  gap: 6px;
  position: sticky;
  top: 16px;
}
.settings-nav-btn {
  text-align: left;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-muted);
  padding: 10px 14px;
  border-radius: 10px;
  font: inherit;
  cursor: pointer;
  transition: color 0.15s, background 0.15s, border-color 0.15s;
}
.settings-nav-btn:hover { color: var(--text); background: rgba(196, 92, 38, 0.08); }
.settings-nav-btn.active {
  color: var(--text);
  background: var(--bg-panel);
  border-color: var(--border);
  box-shadow: none;
}
/* Высота панели = активная вкладка (без пустого скролла) */
.settings-panes {
  background: rgba(255, 252, 245, 0.88);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px 26px;
  backdrop-filter: blur(6px);
}
.settings-pane {
  display: none;
}
.settings-pane.active {
  display: block;
}

.pane-hint { margin: 0 0 18px; color: var(--text-muted); }
.section-title {
  margin: 0 0 10px;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--accent);
  letter-spacing: 0.02em;
}
.section-title--inline { margin: 0; }

.field { margin-bottom: 12px; }
.field-label {
  display: block;
  margin-bottom: 4px;
  color: var(--text-muted);
  font-size: 0.85rem;
}
.field-input {
  width: 100%;
  padding: 9px 11px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  font: inherit;
}
.field-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(196, 92, 38, 0.18);
}
.field-input--mono { font-family: ui-monospace, Consolas, monospace; font-size: 0.9em; }
.field-input--time, .field-input--sm { max-width: 110px; }
.field-input--date { max-width: 160px; }
.field-hint { color: var(--text-muted); font-size: 0.85rem; margin: 6px 0; line-height: 1.45; }
.field-range { display: flex; align-items: center; gap: 10px; }
.field-range input { flex: 1; }
.field-range-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}
.field-range-head .field-label { margin-bottom: 0; }
.field-range-val {
  font-weight: 600;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
  min-width: 1.5em;
  text-align: right;
}
.field-range-input {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 8px;
  margin: 0;
  padding: 0;
  border-radius: 4px;
  background: var(--sand-dim);
  outline: none;
  cursor: pointer;
  accent-color: var(--accent);
}
.field-range-input::-webkit-slider-runnable-track {
  height: 8px;
  border-radius: 4px;
  background: linear-gradient(90deg, var(--sand-dim), var(--accent));
}
.field-range-input::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  margin-top: -5px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px rgba(196, 92, 38, 0.35);
  cursor: pointer;
}
.field-range-input::-moz-range-track {
  height: 8px;
  border-radius: 4px;
  background: linear-gradient(90deg, var(--sand-dim), var(--accent));
}
.field-range-input::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px rgba(196, 92, 38, 0.35);
  cursor: pointer;
}
.field-check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-right: 14px;
  color: var(--text);
  cursor: pointer;
}

.btn {
  border: 1px solid transparent;
  border-radius: 9px;
  padding: 8px 14px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s, background 0.2s, border-color 0.2s;
}
.btn:active { transform: scale(0.98); }
.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-dim));
  color: #fff;
}
.btn-primary:hover { filter: brightness(1.05); }
.btn-secondary {
  background: transparent;
  border-color: var(--border);
  color: var(--text);
}
.btn-secondary:hover { border-color: var(--accent); color: var(--accent); }
.btn-ghost {
  background: transparent;
  color: var(--text-muted);
}
.btn-ghost:hover { color: var(--accent); }
.btn-block { width: 100%; margin-top: 8px; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.visual-layout {
  display: grid;
  grid-template-columns: minmax(180px, 260px) minmax(200px, 320px);
  gap: 20px 48px;
  align-items: start;
  justify-content: start;
}
.visual-colors {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.visual-colors .field { margin-bottom: 0; }
.visual-colors input[type="color"] {
  width: 100%;
  height: 40px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
}
.visual-size {
  margin: 0;
  max-width: 320px;
}

.integ-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 28px;
}
.google-service {
  margin-top: 16px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.55);
}
.google-service-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.google-service-actions { display: flex; gap: 8px; }

.widget-settings-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(300px, 380px);
  gap: 22px;
}
.widget-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.widget-form-block {
  padding: 12px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.55);
  border: 1px solid rgba(196, 92, 38, 0.14);
}
.widget-sched-rows {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 8px 10px;
  align-items: center;
}
.board-page-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.board-page-list li {
  padding: 8px 10px;
  margin-bottom: 6px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: grab;
}
.board-page-list li.dragging { opacity: 0.5; }
.widget-mhs-checks { display: flex; flex-wrap: wrap; gap: 8px 4px; }
.widget-preview-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

/* Предпросмотр = Android RemoteViews (widget_day_plan.xml) */
.widget-preview {
  margin-top: 0;
  max-width: 408px;
  padding: 0;
  border-radius: 0;
  background: transparent;
  color: #2d3142;
  min-height: 460px;
  font-size: 16px;
  font-family: Roboto, "Segoe UI", system-ui, sans-serif;
}
.widget-preview-root {
  background: #ffffff;
  padding: 8px;
  min-height: 460px;
  box-sizing: border-box;
  border: 1px solid rgba(0, 0, 0, 0.12);
}
.widget-preview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 44px;
}
.widget-preview-header-left {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex: 1 1 auto;
}
.widget-preview-date {
  font-weight: 700;
  font-size: 20px;
  line-height: 1.2;
  color: #2d3142;
  margin: 0;
  flex: 0 1 auto;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.widget-preview-finance {
  flex: 0 0 auto;
  font-weight: 700;
  font-size: 14px;
  line-height: 1.2;
  color: #1b5e20;
  white-space: nowrap;
}
.widget-preview-icons {
  display: grid;
  grid-auto-flow: column;
  grid-template-rows: 36px;
  grid-auto-columns: 36px;
  gap: 0 3px;
  justify-content: end;
  flex: 0 0 auto;
  max-width: calc(8 * 36px + 7 * 3px);
}
.widget-preview-icon {
  width: 36px;
  height: 36px;
  border-radius: 0;
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  font-size: 10px;
  font-weight: 700;
  text-align: center;
  padding: 1px;
  box-sizing: border-box;
  opacity: 0.28;
  color: #1b5e20;
}
.widget-preview-icon.lit { opacity: 1; }
.widget-preview-icon img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}
.widget-preview-list { margin-top: 4px; }
.widget-preview-row {
  display: flex;
  align-items: center;
  gap: 0;
  padding: 2px 0;
  min-height: 0;
  border: none;
  background: transparent;
}
.widget-preview-check {
  width: 28px;
  flex: 0 0 28px;
  font-size: 22px;
  line-height: 1;
  color: #2d3142;
  user-select: none;
}
.widget-preview-text {
  flex: 1 1 auto;
  min-width: 0;
  padding-left: 6px;
  font-size: 16px;
  line-height: 1.35;
  color: #2d3142;
  white-space: pre-wrap;
  word-break: break-word;
}
.widget-preview-text.is-done { text-decoration: line-through; opacity: 0.55; }
.widget-preview-divider {
  height: 2px;
  margin: 3px 10px;
  border: none;
  border-radius: 0;
  background: #43a047;
}
.widget-preview-divider.v-google_morning { background: #42a5f5; }
.widget-preview-divider.v-morning_mhs,
.widget-preview-divider.v-green { background: #43a047; }
.widget-preview-divider.v-mhs_dela,
.widget-preview-divider.v-blue { background: #5c6bc0; }
.widget-preview-divider.v-dela_evening { background: #66bb6a; }
.widget-preview-error { color: var(--danger); font-size: 0.9rem; }
.widget-preview-empty {
  padding-top: 8px;
  text-align: center;
  color: #6b7280;
  font-size: 15px;
  min-height: 24px;
}

@media (max-width: 960px) {
  .settings-wrap { grid-template-columns: 1fr; padding: 12px 14px 40px; }
  .settings-nav { flex-direction: row; flex-wrap: wrap; position: static; }
  .integ-grid, .widget-settings-layout, .widget-row { grid-template-columns: 1fr; }
  .visual-layout { grid-template-columns: 1fr; }
  .settings-panes { min-height: 0; }
}
