/* ── App wrapper ─────────────────────────────────────────── */
.app-root {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 16px 60px;
}

/* ── Loading / no-access ─────────────────────────────────── */
.loading-screen, .no-access-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
  gap: 12px;
  color: var(--subtext);
  font-size: 15px;
  text-align: center;
  padding: 40px 20px;
}
.no-access-screen h2 { font-size: 20px; color: var(--text); }
[hidden] { display: none !important; }

/* ── Header ──────────────────────────────────────────────── */
.app-header {
  padding: 16px 0 10px;
  margin-bottom: 4px;
}
.header-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}
.header-nav a {
  font-size: 14px;
  font-weight: 500;
  color: var(--accent);
  text-decoration: none;
}
.header-nav a:hover { text-decoration: underline; }

.header-main {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.household-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}
.brand-title {
  font-size: 26px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.1;
}

/* Week designator */
.wd-control {
  display: flex;
  align-items: center;
  gap: 8px;
}
.wd-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--subtext);
  transition: color 0.15s, font-weight 0.1s;
}
.wd-label.active {
  color: var(--accent);
  font-weight: 700;
}
.wd-arrow-btn {
  background: var(--accent-tint-bg);
  border: 1px solid var(--accent-tint-border);
  color: var(--accent);
  border-radius: 20px;
  padding: 4px 12px;
  font-size: 15px;
  cursor: pointer;
  font-family: var(--font);
  transition: background 0.15s;
}
.wd-arrow-btn:hover { background: var(--accent-tint-border); }
.wd-select {
  font-family: var(--font);
  font-size: 14px;
  color: var(--accent);
  background: var(--accent-tint-bg);
  border: 1px solid var(--accent-tint-border);
  border-radius: 10px;
  padding: 6px 10px;
  cursor: pointer;
}

/* ── Section label ───────────────────────────────────────── */
.section-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--subtext);
  margin-bottom: 10px;
  margin-top: 20px;
}

/* ── Day boxes ───────────────────────────────────────────── */
.days-wrap {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
@media (min-width: 720px) {
  .days-wrap {
    flex-direction: row;
    align-items: stretch;
    overflow-x: auto;
    padding-bottom: 4px;
  }
  .days-wrap::-webkit-scrollbar { height: 4px; }
  .days-wrap::-webkit-scrollbar-thumb { background: var(--line); border-radius: 2px; }
}

.day-box {
  display: flex;
  flex-direction: column;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}
@media (min-width: 720px) {
  .day-box { flex: 1; min-width: 120px; }
}
.day-box-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  gap: 4px;
  flex-shrink: 0;
}
.day-name {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--subtext);
}
.day-desig-select {
  font-family: var(--font);
  font-size: 10px;
  color: var(--accent);
  background: var(--accent-tint-bg);
  border: 1px solid var(--accent-tint-border);
  border-radius: 6px;
  padding: 2px 4px;
  cursor: pointer;
  max-width: 84px;
}
.day-field {
  flex: 1;
  min-height: 48px;
  outline: none;
  font-size: 14px;
  line-height: 1.55;
  color: var(--text);
  font-family: var(--font);
  word-break: break-word;
}
.day-field > div { margin-top: 6px; }
.day-field a { color: var(--accent); cursor: pointer; }

/* ── Workspace (Plan & Shop) ─────────────────────────────── */
.workspace-wrap {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
  align-items: start;
}
@media (min-width: 720px) {
  .workspace-wrap { grid-template-columns: repeat(var(--panel-count, 2), 1fr); }
}

.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
  display: flex;
  flex-direction: column;
  gap: 0;
}

/* List header row */
.list-head {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}
.list-head + .list-head {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}
.list-label {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
}
.list-sub {
  font-size: 12px;
  color: var(--subtext);
}
.info-btn {
  font-size: 13px;
  color: var(--subtext);
  cursor: pointer;
  border: none;
  background: none;
  padding: 0 2px;
  line-height: 1;
  opacity: 0.7;
  font-family: var(--font);
}
.info-btn:hover { opacity: 1; color: var(--accent); }

/* Info popup */
.info-popup {
  position: fixed;
  z-index: 200;
  background: var(--text);
  color: #fff;
  font-size: 13px;
  line-height: 1.5;
  padding: 10px 14px;
  border-radius: 10px;
  max-width: 260px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.2);
  pointer-events: none;
}

/* Rich text field */
.rich-field {
  outline: none;
  font-size: 14px;
  line-height: 1.6;
  color: var(--text);
  font-family: var(--font);
  min-height: 36px;
  word-break: break-word;
}
.rich-field > div { margin-top: 6px; }
.rich-field a { color: var(--accent); cursor: pointer; }

/* ── Checklist ───────────────────────────────────────────── */
.item-rows { margin-bottom: 8px; }

.item-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 2px 0;
}
.item-cb {
  width: 18px; height: 18px;
  border-radius: 5px;
  border: 1.5px solid var(--line);
  flex-shrink: 0;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.15s, border-color 0.15s;
  font-size: 11px;
  color: #fff;
}
.item-cb.checked {
  background: var(--accent);
  border-color: var(--accent);
}
.item-text {
  flex: 1;
  font-size: 14px;
  line-height: 1.4;
  color: var(--text);
}
.item-text.done {
  text-decoration: line-through;
  color: var(--subtext);
}
.item-del {
  color: var(--subtext);
  font-size: 15px;
  cursor: pointer;
  opacity: 0;
  padding: 2px 4px;
  line-height: 1;
  border: none;
  background: none;
  font-family: var(--font);
  flex-shrink: 0;
}
.item-row:hover .item-del { opacity: 0.5; }
.item-del:hover { opacity: 1 !important; color: var(--danger); }

.add-item-input {
  width: 100%;
  border: none;
  border-top: 1px solid var(--line);
  padding: 8px 4px 4px;
  font-family: var(--font);
  font-size: 14px;
  color: var(--subtext);
  outline: none;
  background: transparent;
}
.add-item-input::placeholder { color: var(--line); }
.add-item-input:focus { color: var(--text); }

/* ── Reference section ───────────────────────────────────── */
.ref-section {
  background: var(--ref-bg);
  border-top: 1px solid var(--line);
  margin-top: 24px;
  padding: 22px 16px 24px;
  border-radius: 20px 20px 0 0;
}
.ref-header {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 18px;
}
.ref-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
}
.ref-sub {
  font-size: 11px;
  color: var(--subtext);
}

.staging-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  margin-bottom: 20px;
}
@media (min-width: 720px) {
  .staging-grid { grid-template-columns: repeat(var(--list-count, 1), 1fr); }
}

.staging-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}
.staging-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}
.move-btn {
  font-size: 12px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 7px;
  border: 1px solid var(--accent-tint-border);
  background: var(--accent-tint-bg);
  color: var(--accent);
  cursor: pointer;
  white-space: nowrap;
  font-family: var(--font);
}
.move-btn:hover { background: var(--accent-tint-border); }

.ref-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}
@media (min-width: 720px) {
  .ref-grid { grid-template-columns: 1fr 1fr 1fr; }
}
.ref-panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}
.ref-field-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--subtext);
  margin-bottom: 8px;
}
.ref-field {
  outline: none;
  font-size: 14px;
  line-height: 1.6;
  color: var(--text);
  font-family: var(--font);
  min-height: 60px;
  word-break: break-word;
}
.ref-field > div { margin-top: 6px; }
.ref-field a { color: var(--accent); cursor: pointer; }
.ref-field:empty::before {
  content: attr(data-placeholder);
  color: var(--line);
  pointer-events: none;
}

/* ── Reset slider ────────────────────────────────────────── */
.reset-wrap {
  padding: 28px 16px 48px;
  text-align: center;
  max-width: 1200px;
  margin: 0 auto;
}
.reset-track {
  position: relative;
  height: 52px;
  background: #f2f2f7;
  border-radius: 26px;
  overflow: hidden;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  touch-action: pan-y;
}
.reset-fill {
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 0;
  background: rgba(220,50,47,0.12);
  pointer-events: none;
}
.reset-label {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 500;
  color: var(--subtext);
  pointer-events: none;
}
.reset-knob {
  position: absolute;
  left: 4px; top: 4px; bottom: 4px;
  width: 44px;
  background: white;
  border-radius: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.15);
  color: var(--subtext);
}
.reset-caption {
  font-size: 12px;
  color: var(--subtext);
  margin-top: 10px;
  line-height: 1.5;
}

/* ── Large text overrides ────────────────────────────────── */
[data-size="large"] .day-field,
[data-size="large"] .rich-field,
[data-size="large"] .ref-field,
[data-size="large"] .item-text,
[data-size="large"] .add-item-input,
[data-size="large"] .list-label,
[data-size="large"] .brand-title { font-size: calc(1em + 2px); }
[data-size="large"] .brand-title { font-size: 28px; }
[data-size="large"] .day-field   { font-size: 16px; }
[data-size="large"] .rich-field  { font-size: 16px; }
[data-size="large"] .ref-field   { font-size: 16px; }
[data-size="large"] .item-text   { font-size: 16px; }
[data-size="large"] .add-item-input { font-size: 16px; }
[data-size="large"] .list-label  { font-size: 16px; }

/* ── Viewer mode ─────────────────────────────────────────── */
body.viewer-mode [contenteditable] { cursor: default; }
body.viewer-mode .item-cb { cursor: default; pointer-events: none; }
body.viewer-mode .item-del { display: none; }
body.viewer-mode .move-btn { display: none; }
body.viewer-mode .reset-wrap { display: none; }
body.viewer-mode #settingsLink { display: none; }
