/* ===== Heritage Craft: Atelier ===== */
[hidden] { display: none !important; }

:root {
  --bg: #fbf7f1;
  --bg-alt: #f3ece1;
  --surface: #ffffff;
  --surface-2: #faf5ec;
  --text: #1a120b;
  --text-soft: #4f4234;
  --muted: #8a7860;
  --border: #e6dccb;
  --primary: #1f5b53;
  --primary-hover: #163f39;
  --accent: #c9a24b;
  --accent-soft: #f1dca6;
  --danger: #b3261e;
  --success: #2e7d32;
  --warning: #b07000;
  --shadow: 0 4px 16px rgba(40, 25, 10, 0.08);
  --shadow-lg: 0 16px 48px rgba(40, 25, 10, 0.18);
  --radius: 10px;
  --radius-sm: 6px;
  --font: 'Helvetica Neue', Arial, system-ui, sans-serif;
  --font-display: 'Georgia', 'Times New Roman', serif;
}

[data-theme="dark"] {
  --bg: #15110d;
  --bg-alt: #1d1813;
  --surface: #221c16;
  --surface-2: #2a231b;
  --text: #f4ece0;
  --text-soft: #d8cab4;
  --muted: #a59madj;
  --muted: #a5947b;
  --border: #3a3127;
  --primary: #3f9b8e;
  --primary-hover: #4fb3a4;
  --accent: #e0bb63;
  --accent-soft: #4a3d22;
  --shadow: 0 4px 16px rgba(0,0,0,0.4);
  --shadow-lg: 0 16px 48px rgba(0,0,0,0.55);
}

@media (prefers-color-scheme: dark) {
  [data-theme="auto"] {
    --bg: #15110d; --bg-alt: #1d1813; --surface: #221c16; --surface-2: #2a231b;
    --text: #f4ece0; --text-soft: #d8cab4; --muted: #a5947b; --border: #3a3127;
    --primary: #3f9b8e; --primary-hover: #4fb3a4; --accent: #e0bb63; --accent-soft: #4a3d22;
    --shadow: 0 4px 16px rgba(0,0,0,0.4); --shadow-lg: 0 16px 48px rgba(0,0,0,0.55);
  }
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; scroll-padding-top: 80px; }

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text-soft);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { font-family: var(--font-display); color: var(--text); line-height: 1.2; margin: 0 0 .5rem; }
h1 { font-size: clamp(2rem, 5vw, 3.5rem); }
h2 { font-size: clamp(1.6rem, 3.5vw, 2.4rem); }
h3 { font-size: 1.25rem; }
p { margin: 0 0 1rem; }

.container { max-width: 1180px; margin: 0 auto; padding: 0 1.25rem; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.skip-link { position: absolute; left: -999px; top: 0; background: var(--primary); color: #fff; padding: .6rem 1rem; z-index: 100; }
.skip-link:focus { left: 8px; top: 8px; border-radius: var(--radius-sm); }

.muted { color: var(--muted); }
.muted-lead { color: var(--muted); max-width: 60ch; margin-top: -.25rem; }

/* ===== Header ===== */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(140%) blur(8px);
  border-bottom: 1px solid var(--border);
}
.header-inner { display: flex; align-items: center; justify-content: space-between; height: 70px; gap: 1rem; }
.brand { display: flex; align-items: center; gap: .65rem; text-decoration: none; color: var(--text); background: none; border: none; cursor: pointer; padding: 0; }
.brand-mark {
  width: 42px; height: 42px; border-radius: 12px; flex: 0 0 auto;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: #fff; font-family: var(--font-display); font-weight: 700; font-size: 1.1rem;
  display: grid; place-items: center; letter-spacing: .5px;
}
.brand-text { font-family: var(--font-display); font-size: 1.25rem; font-weight: 700; display: flex; flex-direction: column; line-height: 1.1; }
.brand-text small { font-family: var(--font); font-size: .62rem; font-weight: 400; letter-spacing: 1.5px; text-transform: uppercase; color: var(--muted); }

.main-nav { display: flex; align-items: center; gap: .35rem; }
.nav-link {
  background: none; border: none; font: inherit; color: var(--text-soft); cursor: pointer;
  padding: .55rem .8rem; border-radius: var(--radius-sm); font-size: .95rem;
  transition: .15s ease;
}
.nav-link:hover { background: var(--surface-2); color: var(--text); }
.nav-link.active { color: var(--primary); font-weight: 600; background: var(--surface-2); }
[data-theme="dark"] .nav-link.active, .nav-link.active { box-shadow: inset 0 -2px 0 var(--accent); }

.nav-toggle { display: none; background: none; border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: 1.3rem; cursor: pointer; color: var(--text); width: 44px; height: 44px; }
.icon-btn { background: none; border: 1px solid var(--border); border-radius: var(--radius-sm); cursor: pointer; color: var(--text); width: 40px; height: 40px; font-size: 1.1rem; display: grid; place-items: center; transition: .15s ease; }
.icon-btn:hover { background: var(--surface-2); }
.theme-btn { margin-left: .4rem; }

/* ===== Views ===== */
.view { display: none; }
.view.active { display: block; animation: fade .25s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.section { padding: 3rem 0; }

.section-title { position: relative; margin-bottom: 1.5rem; }
.section-title::after { content: ''; display: block; width: 50px; height: 3px; background: var(--accent); margin-top: .5rem; }

/* ===== Hero ===== */
.hero {
  position: relative; color: #f4ece0; overflow: hidden;
  background:
    linear-gradient(rgba(20,17,13,0.72), rgba(20,17,13,0.88)),
    radial-gradient(circle at 30% 30%, #1f5b53, #0e0b08 72%);
}
.hero::before {
  content: ''; position: absolute; inset: 0;
  background-image: repeating-linear-gradient(45deg, var(--accent) 0, var(--accent) 1px, transparent 1px, transparent 14px);
  opacity: .04;
}
.hero-inner { position: relative; padding: 4.5rem 1.25rem 3.5rem; max-width: 1180px; }
.eyebrow { text-transform: uppercase; letter-spacing: 2px; font-size: .78rem; color: var(--accent); font-weight: 600; margin-bottom: .6rem; }
.hero h1 { color: #fff; max-width: 18ch; }
.lead { font-size: 1.12rem; max-width: 56ch; color: #e6ddcd; }
.hero-cta { display: flex; gap: .8rem; flex-wrap: wrap; margin: 1.6rem 0 2.2rem; }

.stats-strip { display: flex; flex-wrap: wrap; gap: 2.4rem; border-top: 1px solid rgba(255,255,255,.16); padding-top: 1.6rem; }
.stat { display: flex; flex-direction: column; }
.stat-num { font-family: var(--font-display); font-size: 2.1rem; color: var(--accent); line-height: 1; }
.stat-label { text-transform: uppercase; letter-spacing: 1px; font-size: .68rem; color: #cdbfa9; margin-top: .35rem; }

/* ===== Buttons ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  min-height: 44px; padding: 0 1.3rem; border-radius: var(--radius-sm); cursor: pointer;
  font: inherit; font-weight: 600; border: 1px solid transparent; transition: .15s ease; text-decoration: none;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-ghost { background: transparent; border-color: var(--border); color: var(--text); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { filter: brightness(.92); }
.btn-sm { min-height: 36px; padding: 0 .85rem; font-size: .85rem; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.link-btn { display: block; background: none; border: none; color: var(--text-soft); cursor: pointer; padding: .25rem 0; font: inherit; text-align: left; }
.link-btn:hover { color: var(--primary); }

/* ===== Cards ===== */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.4rem; box-shadow: var(--shadow); transition: .15s ease; }
.grid-2 { display: grid; grid-template-columns: 1fr 1.2fr; gap: 1.6rem; align-items: start; }

/* ===== Forms ===== */
.field { margin-bottom: 1rem; }
.field-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; }
.field label { display: block; font-size: .82rem; font-weight: 600; color: var(--text); margin-bottom: .35rem; text-transform: uppercase; letter-spacing: .5px; }
.field .hint { text-transform: none; font-weight: 400; color: var(--muted); letter-spacing: 0; }
input[type=text], input[type=number], input[type=date], input[type=password], textarea, .select {
  width: 100%; padding: .7rem .8rem; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface-2); color: var(--text); font: inherit; transition: .15s ease;
}
textarea { resize: vertical; }
input:focus, textarea:focus, .select:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 22%, transparent); }
input.error, textarea.error { border-color: var(--danger); }
input.valid, textarea.valid { border-color: var(--success); }
.color-input { width: 60px; height: 44px; padding: 4px; }
.field-msg { display: block; min-height: 1.1em; font-size: .78rem; margin-top: .3rem; color: var(--muted); }
.field-msg.error { color: var(--danger); }
.field-msg.valid { color: var(--success); }
.select-wrap { display: inline-flex; }
.select { width: auto; min-width: 200px; cursor: pointer; }

.day-picker { display: flex; gap: .4rem; flex-wrap: wrap; }
.day-chip { position: relative; cursor: pointer; }
.day-chip input { position: absolute; opacity: 0; }
.day-chip span { display: inline-block; padding: .45rem .7rem; border: 1px solid var(--border); border-radius: 999px; font-size: .82rem; background: var(--surface-2); transition: .15s ease; }
.day-chip input:checked + span { background: var(--primary); color: #fff; border-color: var(--primary); }

.modal-actions { display: flex; justify-content: flex-end; gap: .7rem; margin-top: 1.2rem; }

/* ===== Dashboard ===== */
.dash-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.dash-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.2rem; margin-bottom: 1.4rem; }
.dash-eta { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1.2rem; margin-bottom: 1.4rem; }
.metric-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.2rem; box-shadow: var(--shadow); }
.metric-card .k { text-transform: uppercase; letter-spacing: 1px; font-size: .68rem; color: var(--muted); }
.metric-card .v { font-family: var(--font-display); font-size: 1.6rem; color: var(--text); margin-top: .3rem; }
.task-spotlight { background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--accent); border-radius: var(--radius); padding: 1.3rem; box-shadow: var(--shadow); }
.task-spotlight .tag { text-transform: uppercase; letter-spacing: 1.5px; font-size: .68rem; color: var(--muted); }
.task-spotlight h3 { margin: .35rem 0 .6rem; }
.spot-meta { display: flex; gap: 1.2rem; flex-wrap: wrap; font-size: .88rem; color: var(--muted); }

.progress { height: 12px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: linear-gradient(90deg, var(--primary), var(--accent)); }

/* ===== Badges & chips ===== */
.badge { display: inline-block; padding: .2rem .6rem; border-radius: 999px; font-size: .72rem; font-weight: 600; text-transform: uppercase; letter-spacing: .5px; }
.badge.todo { background: var(--surface-2); color: var(--muted); }
.badge.in-progress { background: #d9eaff; color: #1d4e89; }
.badge.done { background: #d8efd9; color: #2e7d32; }
.badge.blocked { background: #f6dcda; color: #b3261e; }
[data-theme="dark"] .badge.in-progress { background: #1d3a5c; color: #9cc7ff; }
[data-theme="dark"] .badge.done { background: #1e3a20; color: #8fd694; }
[data-theme="dark"] .badge.blocked { background: #4a1f1c; color: #f0a39d; }

.chip-row { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: 1rem; }
.chip { border: 1px solid var(--border); background: var(--surface); color: var(--text-soft); border-radius: 999px; padding: .4rem .9rem; cursor: pointer; font: inherit; font-size: .85rem; transition: .15s ease; }
.chip:hover { border-color: var(--primary); }
.chip.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ===== Ideas ===== */
.idea-list { display: flex; flex-direction: column; gap: .9rem; }
.idea-item { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.1rem 1.2rem; box-shadow: var(--shadow); transition: .15s ease; }
.idea-item:hover { transform: translateY(-3px); }
.idea-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; }
.idea-head h4 { margin: 0; }
.idea-notes { color: var(--text-soft); font-size: .92rem; margin: .5rem 0 .7rem; }
.idea-tags { display: flex; gap: .4rem; flex-wrap: wrap; margin-bottom: .7rem; }
.tag-pill { font-size: .7rem; background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px; padding: .15rem .55rem; color: var(--muted); }
.idea-actions { display: flex; gap: .5rem; flex-wrap: wrap; }

/* ===== Projects ===== */
.project-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1.2rem; }
.project-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.3rem; box-shadow: var(--shadow); transition: .15s ease; cursor: pointer; position: relative; overflow: hidden; }
.project-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.project-card .pc-bar { position: absolute; left: 0; top: 0; bottom: 0; width: 5px; }
.project-card h3 { margin-bottom: .3rem; }
.pc-meta { font-size: .82rem; color: var(--muted); margin: .6rem 0; display: flex; gap: 1rem; flex-wrap: wrap; }
.pc-progress-line { display: flex; justify-content: space-between; font-size: .78rem; color: var(--muted); margin: .7rem 0 .35rem; }
.pc-actions { display: flex; gap: .5rem; margin-top: 1rem; flex-wrap: wrap; }

.project-detail { margin-top: 2.2rem; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.5rem; }
.detail-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.2rem; }
.task-table { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.task-table th, .task-table td { padding: .7rem .8rem; text-align: left; border-bottom: 1px solid var(--border); font-size: .9rem; }
.task-table th { background: var(--bg-alt); text-transform: uppercase; letter-spacing: .5px; font-size: .72rem; color: var(--muted); }
.task-table tr:last-child td { border-bottom: none; }
.task-table .num { font-family: var(--font-display); color: var(--muted); }
.row-actions { display: flex; gap: .3rem; }
.row-actions .icon-btn { width: 32px; height: 32px; font-size: .9rem; }
.task-table tr.done td:nth-child(2) { text-decoration: line-through; color: var(--muted); }

.empty { text-align: center; padding: 3rem 1rem; color: var(--muted); border: 2px dashed var(--border); border-radius: var(--radius); }
.empty .em { font-size: 2.5rem; display: block; margin-bottom: .5rem; }

/* ===== Gantt ===== */
.gantt-legend { display: flex; gap: 1.2rem; flex-wrap: wrap; margin-bottom: 1rem; font-size: .82rem; color: var(--muted); }
.legend-item { display: flex; align-items: center; gap: .4rem; }
.legend-swatch { width: 14px; height: 14px; border-radius: 3px; }
.gantt { display: flex; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: var(--surface); }
.gantt-labels { flex: 0 0 220px; border-right: 1px solid var(--border); background: var(--surface); z-index: 2; }
.gantt-corner { height: 52px; padding: .6rem .9rem; border-bottom: 1px solid var(--border); font-weight: 600; font-size: .8rem; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); background: var(--bg-alt); display: flex; align-items: center; }
.glabel { height: 40px; padding: 0 .9rem; border-bottom: 1px solid var(--border); display: flex; align-items: center; font-size: .85rem; gap: .5rem; overflow: hidden; }
.glabel .gl-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gantt-scroll { overflow-x: auto; flex: 1; }
.gantt-timeline { position: relative; }
.gantt-head { display: flex; flex-direction: column; height: 52px; border-bottom: 1px solid var(--border); position: relative; }
.gantt-months { display: flex; height: 26px; }
.gantt-month { border-right: 1px solid var(--border); font-size: .72rem; font-weight: 600; color: var(--text); display: flex; align-items: center; padding: 0 .5rem; text-transform: uppercase; letter-spacing: .5px; background: var(--bg-alt); }
.gantt-days { display: flex; height: 26px; }
.gantt-day { flex: 0 0 auto; border-right: 1px solid var(--border); font-size: .62rem; text-align: center; color: var(--muted); padding-top: 2px; line-height: 1.1; }
.gantt-day.nonwork { background: var(--bg-alt); }
.gantt-rows { position: relative; }
.grow { height: 40px; border-bottom: 1px solid var(--border); position: relative; }
.col-shade { position: absolute; top: 0; bottom: 0; background: color-mix(in srgb, var(--muted) 8%, transparent); pointer-events: none; }
.today-line { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--danger); z-index: 3; }
.today-line::after { content: 'Today'; position: absolute; top: -18px; left: -16px; font-size: .6rem; color: var(--danger); background: var(--surface); padding: 0 3px; }
.gbar { position: absolute; top: 8px; height: 24px; border-radius: 6px; display: flex; align-items: center; padding: 0 .5rem; font-size: .72rem; color: #fff; white-space: nowrap; overflow: hidden; box-shadow: var(--shadow); z-index: 2; }
.gbar.todo { background: var(--muted); }
.gbar.in-progress { background: var(--primary); }
.gbar.done { background: var(--success); }
.gbar.blocked { background: var(--danger); }

/* ===== Settings ===== */
.settings-card { max-width: 560px; }
.settings-block { margin-bottom: 1.8rem; }
.kbd { background: var(--surface-2); border: 1px solid var(--border); border-radius: 4px; padding: .1rem .4rem; font-family: monospace; font-size: .8rem; }
.danger-zone { border: 1px solid var(--danger); border-radius: var(--radius); padding: 1.2rem; }

/* ===== Footer ===== */
.site-footer { background: var(--surface); border-top: 1px solid var(--border); margin-top: 2rem; }
.footer-grid { display: grid; grid-template-columns: 2fr 1fr 1fr 1fr; gap: 1.6rem; padding: 3rem 1.25rem 2rem; }
.footer-grid h4 { font-size: .9rem; }
.footer-brand { margin-bottom: .8rem; }
.social-row { display: flex; gap: .5rem; }
.social-chip { width: 38px; height: 38px; border-radius: 50%; background: var(--surface-2); border: 1px solid var(--border); display: grid; place-items: center; cursor: pointer; }
.footer-bottom { border-top: 1px solid var(--border); padding: 1.2rem 1.25rem; text-align: center; font-size: .82rem; color: var(--muted); }

/* ===== Modal ===== */
.modal { position: fixed; inset: 0; z-index: 80; background: rgba(20,17,13,.55); padding: 1.25rem; align-items: flex-start; justify-content: center; overflow-y: auto; }
.modal-card { background: var(--surface); border-radius: var(--radius); width: 100%; max-width: 560px; margin-top: 6vh; box-shadow: var(--shadow-lg); animation: pop .2s ease; }
@keyframes pop { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 1.2rem 1.4rem; border-bottom: 1px solid var(--border); }
.modal-head h3 { margin: 0; }
.modal-card form { padding: 1.4rem; }

/* ===== Toast ===== */
.toast-wrap { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 100; display: flex; flex-direction: column; gap: .6rem; align-items: center; }
.toast { background: var(--text); color: var(--bg); padding: .8rem 1.2rem; border-radius: var(--radius-sm); box-shadow: var(--shadow-lg); font-size: .9rem; opacity: 0; transform: translateY(20px); transition: .25s ease; max-width: 90vw; }
.toast.show { opacity: 1; transform: none; }
.toast.success { background: var(--success); color: #fff; }
.toast.error { background: var(--danger); color: #fff; }

/* ===== Responsive ===== */
@media (max-width: 1024px) {
  .grid-2 { grid-template-columns: 1fr; }
  .dash-eta { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 880px) {
  .nav-toggle { display: block; }
  .main-nav {
    position: absolute; top: 70px; left: 0; right: 0; flex-direction: column; align-items: stretch;
    background: var(--surface); border-bottom: 1px solid var(--border); padding: 0 1.25rem; gap: 0;
    max-height: 0; overflow: hidden; transition: max-height .25s ease;
  }
  .main-nav.open { max-height: 420px; padding: .6rem 1.25rem; }
  .nav-link { padding: .8rem .4rem; text-align: left; }
  .footer-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 640px) {
  .dash-grid, .dash-eta { grid-template-columns: 1fr; }
  .field-row { grid-template-columns: 1fr; }
  .footer-grid { grid-template-columns: 1fr; }
  .stats-strip { gap: 1.4rem; }
}
@media (max-width: 480px) {
  .hero-inner { padding: 3rem 1.25rem 2.5rem; }
}
