/* ============================================================
   Hui Chun Gong – Projektmodul
   Aesthetik: "Rueckkehr des Fruehlings" – Jade, Pergament, Tinte
   ============================================================ */

:root {
  --paper: #f5f1e8;
  --paper-2: #efe9db;
  --surface: #fffdf8;
  --ink: #2b2a24;
  --ink-soft: #5c594e;
  --ink-faint: #8d897b;
  --jade: #3f6f53;
  --jade-deep: #2c5640;
  --jade-soft: #e2ece3;
  --clay: #b9683f;
  --clay-soft: #f3e3d6;
  --gold: #c19a4b;
  --line: #e3ddcf;
  --line-strong: #d3ccb9;
  --danger: #b0463a;
  --shadow: 0 1px 2px rgba(43, 42, 36, .04), 0 8px 24px rgba(43, 42, 36, .06);
  --shadow-lg: 0 4px 12px rgba(43, 42, 36, .08), 0 24px 48px rgba(43, 42, 36, .10);
  --radius: 14px;
  --radius-sm: 9px;
  --font-display: "Fraunces", Georgia, serif;
  --font-body: "Spline Sans", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0; height: 100%;
}

body {
  font-family: var(--font-body);
  color: var(--ink);
  background-color: var(--paper);
  background-image:
    radial-gradient(circle at 12% -10%, rgba(63, 111, 83, .07), transparent 40%),
    radial-gradient(circle at 95% 0%, rgba(193, 154, 75, .06), transparent 35%);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }

button { font-family: inherit; cursor: pointer; }

/* ---------- Login ---------- */
.login-overlay {
  position: fixed; inset: 0; z-index: 100;
  display: grid; place-items: center;
  background: linear-gradient(160deg, #eef2ea, #f5f1e8 60%, #f0e7d8);
}
.login-card {
  width: min(380px, 90vw);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 40px 34px 30px;
  box-shadow: var(--shadow-lg);
  text-align: center;
  animation: rise .5s cubic-bezier(.16,1,.3,1);
}
.login-mark {
  font-family: var(--font-display);
  font-size: 38px; font-weight: 500;
  color: var(--jade);
  letter-spacing: 4px;
  margin-bottom: 6px;
}
.login-card h1 {
  font-family: var(--font-display);
  font-weight: 600; font-size: 26px;
  margin: 0; color: var(--ink);
}
.login-sub { color: var(--ink-faint); margin: 4px 0 26px; font-size: 14px; }
#login-form { display: flex; flex-direction: column; gap: 12px; }
#login-pw, .field input, .field select, .field textarea {
  width: 100%;
  padding: 11px 14px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-family: inherit; font-size: 15px; color: var(--ink);
  transition: border-color .15s, box-shadow .15s;
}
#login-pw:focus, .field input:focus, .field select:focus, .field textarea:focus {
  outline: none; border-color: var(--jade);
  box-shadow: 0 0 0 3px var(--jade-soft);
}
#login-form button {
  padding: 12px; border: none; border-radius: var(--radius-sm);
  background: var(--jade); color: #fff; font-size: 15px; font-weight: 500;
  transition: background .15s, transform .05s;
}
#login-form button:hover { background: var(--jade-deep); }
#login-form button:active { transform: translateY(1px); }
.login-error { color: var(--danger); font-size: 14px; min-height: 18px; margin: 12px 0 0; }

/* ---------- Topbar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 18px;
  padding: 12px 24px;
  background: rgba(255, 253, 248, .85);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 11px; }
.brand-mark {
  font-family: var(--font-display); font-size: 22px; font-weight: 500;
  color: var(--jade); letter-spacing: 1px;
  width: 42px; height: 42px; display: grid; place-items: center;
  background: var(--jade-soft); border-radius: 12px;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text strong { font-family: var(--font-display); font-size: 16px; font-weight: 600; }
.brand-text span { font-size: 12px; color: var(--ink-faint); }

.tabs { display: flex; gap: 2px; margin-left: 8px; flex: 1; flex-wrap: wrap; }
.tabs button {
  border: none; background: transparent;
  padding: 8px 15px; border-radius: 999px;
  font-size: 14px; font-weight: 500; color: var(--ink-soft);
  transition: background .15s, color .15s;
}
.tabs button:hover { background: var(--paper-2); color: var(--ink); }
.tabs button.active { background: var(--ink); color: var(--paper); }

.logout {
  border: 1px solid var(--line-strong); background: transparent;
  padding: 8px 14px; border-radius: 999px; font-size: 13px; color: var(--ink-soft);
  transition: border-color .15s, color .15s;
}
.logout:hover { border-color: var(--clay); color: var(--clay); }

/* ---------- Main / Layout ---------- */
.main { max-width: 1080px; margin: 0 auto; padding: 30px 24px 80px; }

.view-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 22px; gap: 16px; flex-wrap: wrap; }
.view-head h2 { font-family: var(--font-display); font-weight: 600; font-size: 30px; margin: 0; letter-spacing: -.3px; }
.view-head .sub { color: var(--ink-faint); font-size: 14px; }

.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
}

/* ---------- Dashboard ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 28px; }
.stat {
  padding: 20px 22px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow);
  position: relative; overflow: hidden;
}
.stat::after { content: ""; position: absolute; right: -20px; top: -20px; width: 70px; height: 70px; border-radius: 50%; background: var(--jade-soft); opacity: .6; }
.stat .num { font-family: var(--font-display); font-size: 40px; font-weight: 600; line-height: 1; color: var(--jade-deep); position: relative; }
.stat .lbl { font-size: 13px; color: var(--ink-soft); margin-top: 8px; position: relative; }

.dash-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.dash-panel { padding: 20px 22px; }
.dash-panel h3 { font-family: var(--font-display); font-size: 18px; margin: 0 0 14px; font-weight: 600; }
.dash-panel ul { list-style: none; margin: 0; padding: 0; }
.dash-panel li { padding: 9px 0; border-bottom: 1px dashed var(--line); font-size: 14px; display: flex; gap: 8px; align-items: baseline; }
.dash-panel li:last-child { border-bottom: none; }
.dash-empty { color: var(--ink-faint); font-size: 14px; }

/* ---------- Listen / Items ---------- */
.toolbar { display: flex; gap: 10px; margin-bottom: 18px; flex-wrap: wrap; align-items: center; }
.btn {
  border: none; background: var(--jade); color: #fff;
  padding: 10px 18px; border-radius: var(--radius-sm);
  font-size: 14px; font-weight: 500; transition: background .15s, transform .05s;
}
.btn:hover { background: var(--jade-deep); }
.btn:active { transform: translateY(1px); }
.btn.ghost { background: transparent; color: var(--ink-soft); border: 1px solid var(--line-strong); }
.btn.ghost:hover { border-color: var(--jade); color: var(--jade); }
.btn.small { padding: 6px 12px; font-size: 13px; }

.filter-chip {
  border: 1px solid var(--line-strong); background: transparent; color: var(--ink-soft);
  padding: 6px 13px; border-radius: 999px; font-size: 13px;
}
.filter-chip.active { background: var(--ink); color: var(--paper); border-color: var(--ink); }

.list { display: flex; flex-direction: column; gap: 10px; }
.item {
  display: flex; align-items: flex-start; gap: 14px;
  padding: 15px 18px; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
  transition: box-shadow .15s, transform .1s;
}
.item:hover { box-shadow: var(--shadow-lg); }
.item-main { flex: 1; min-width: 0; }
.item-title { font-size: 15px; font-weight: 600; color: var(--ink); }
.item-title.done { text-decoration: line-through; color: var(--ink-faint); }
.item-meta { font-size: 12.5px; color: var(--ink-faint); margin-top: 4px; display: flex; gap: 12px; flex-wrap: wrap; }
.item-desc { font-size: 13.5px; color: var(--ink-soft); margin-top: 7px; white-space: pre-wrap; word-break: break-word; }
.item-actions { display: flex; gap: 6px; flex-shrink: 0; }
.icon-btn {
  border: none; background: transparent; color: var(--ink-faint);
  width: 30px; height: 30px; border-radius: 8px; font-size: 15px;
  display: grid; place-items: center; transition: background .15s, color .15s;
}
.icon-btn:hover { background: var(--paper-2); color: var(--ink); }
.icon-btn.del:hover { background: var(--clay-soft); color: var(--danger); }

/* Status checkbox (Aufgaben) */
.check {
  width: 22px; height: 22px; border-radius: 7px; flex-shrink: 0; margin-top: 1px;
  border: 2px solid var(--line-strong); background: var(--surface);
  display: grid; place-items: center; color: transparent; cursor: pointer;
  transition: all .15s; font-size: 13px;
}
.check.partial { border-color: var(--gold); color: var(--gold); }
.check.done { border-color: var(--jade); background: var(--jade); color: #fff; }

/* Badges */
.badge { font-size: 11px; font-weight: 600; padding: 2px 9px; border-radius: 999px; letter-spacing: .2px; }
.badge.telegram { background: #e4f0fb; color: #2c6fa6; }
.badge.web { background: var(--paper-2); color: var(--ink-soft); }
.badge.prio-hoch { background: var(--clay-soft); color: var(--clay); }
.badge.prio-niedrig { background: var(--jade-soft); color: var(--jade-deep); }
.tag { font-size: 11px; padding: 2px 8px; border-radius: 6px; background: var(--paper-2); color: var(--ink-soft); }

.empty-state { text-align: center; padding: 60px 20px; color: var(--ink-faint); }
.empty-state .big { font-family: var(--font-display); font-size: 22px; color: var(--ink-soft); margin-bottom: 6px; }

/* ---------- Modal-Formular ---------- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 60; display: grid; place-items: center;
  background: rgba(43, 42, 36, .35); backdrop-filter: blur(2px); padding: 20px;
  animation: fade .2s ease;
}
.modal {
  width: min(520px, 100%); background: var(--surface); border-radius: 18px;
  box-shadow: var(--shadow-lg); border: 1px solid var(--line);
  max-height: 90vh; overflow: auto; animation: rise .3s cubic-bezier(.16,1,.3,1);
}
.modal-head { padding: 22px 26px 0; }
.modal-head h3 { font-family: var(--font-display); font-size: 22px; margin: 0; font-weight: 600; }
.modal-body { padding: 18px 26px 26px; display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 13px; font-weight: 500; color: var(--ink-soft); }
.field textarea { resize: vertical; min-height: 80px; }
.field-row { display: flex; gap: 14px; }
.field-row .field { flex: 1; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; margin-top: 6px; }

/* ---------- Mindmap ---------- */
.mindmap-wrap { display: flex; flex-direction: column; height: calc(100vh - 220px); min-height: 420px; }
#jsmind_container {
  flex: 1; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface); box-shadow: var(--shadow); overflow: hidden;
}
jmnode {
  font-family: var(--font-body) !important; font-size: 14px !important;
  background: var(--surface) !important; color: var(--ink) !important;
  border: 1px solid var(--line-strong) !important; border-radius: 9px !important;
  box-shadow: 0 1px 3px rgba(43,42,36,.08) !important;
}
jmnode:hover { box-shadow: 0 2px 8px rgba(43,42,36,.15) !important; }
jmnode.selected { background: var(--jade-soft) !important; border-color: var(--jade) !important; }
jmnode.root {
  background: var(--jade) !important; color: #fff !important;
  border-color: var(--jade-deep) !important; font-family: var(--font-display) !important;
  font-weight: 600 !important; font-size: 16px !important;
}
jmexpander { color: var(--jade) !important; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; bottom: 26px; left: 50%; transform: translate(-50%, 20px);
  background: var(--ink); color: var(--paper); padding: 12px 22px; border-radius: 999px;
  font-size: 14px; box-shadow: var(--shadow-lg); opacity: 0; pointer-events: none;
  transition: opacity .25s, transform .25s; z-index: 200;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.err { background: var(--danger); }

@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: translateY(0); } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

@media (max-width: 720px) {
  .dash-cols { grid-template-columns: 1fr; }
  .topbar { flex-wrap: wrap; }
  .tabs { order: 3; width: 100%; }
  .view-head h2 { font-size: 24px; }
  .field-row { flex-direction: column; gap: 14px; }
}

/* --- Phase 2: User + Projects --- */
.topbar-user { display: flex; align-items: center; gap: 10px; }
.user-badge {
  background: var(--accent, #2f7a4d);
  color: #fff;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 500;
}
.project-bar { margin-bottom: 6px; }
.project-bar .filter-chip { font-size: 13px; }
.item-audit {
  margin-top: 6px;
  font-size: 12px;
  color: var(--muted, #8a8f87);
  font-style: italic;
}

/* --- Dashboard klickbar --- */
.stat.clickable { cursor: pointer; transition: transform .12s, box-shadow .12s; }
.stat.clickable:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.dash-panel li.clickable {
  cursor: pointer; border-radius: 6px; padding-left: 6px; padding-right: 6px;
  margin-left: -6px; margin-right: -6px;
  transition: background .12s;
}
.dash-panel li.clickable:hover { background: var(--jade-soft); }
.dash-panel h3.clickable { cursor: pointer; display: inline-flex; align-items: center; gap: 4px; }
.dash-panel h3.clickable:hover { color: var(--jade); }
.dash-panel h3 .h3-arrow { opacity: 0; transition: opacity .12s, transform .12s; display: inline-block; }
.dash-panel h3.clickable:hover .h3-arrow { opacity: 1; transform: translateX(3px); }
.item-title.clickable { cursor: pointer; }
.item-title.clickable:hover { color: var(--jade); }

/* --- Hamburger + Mobile-Menue --- */
.hamburger {
  display: none;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  width: 40px; height: 40px;
  border-radius: 10px;
  font-size: 20px;
  color: var(--ink);
  align-items: center;
  justify-content: center;
}

@media (max-width: 720px) {
  .topbar {
    flex-wrap: wrap;
    align-items: center;
    padding: 12px 14px;
  }
  .brand { flex: 1; }
  .hamburger { display: inline-flex; }
  .topbar-user { margin-left: auto; }

  /* Tabs als ausklappbares Vertikalmenue */
  .tabs {
    order: 99;
    width: 100%;
    flex-direction: column;
    align-items: stretch;
    gap: 4px;
    margin: 10px 0 0;
    max-height: 0;
    overflow: hidden;
    transition: max-height .25s ease;
  }
  body.menu-open .tabs { max-height: 500px; }
  .tabs button {
    text-align: left;
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    font-size: 15px;
  }

  /* Kompaktere Listen + Karten */
  .main { padding: 18px 12px 80px; }
  .view-head { gap: 10px; margin-bottom: 16px; }
  .view-head h2 { font-size: 22px; }
  .item { padding: 12px 14px; gap: 10px; }
  .item-actions { gap: 4px; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .stat { padding: 14px 16px; }
  .stat .num { font-size: 30px; }
  .stat .lbl { font-size: 12px; }

  /* Login-Card kleiner */
  .login-card { padding: 28px 22px 22px; }
}

/* --- Externe Links in Notizen --- */
.ext-link {
  display: inline-block;
  background: var(--jade-soft);
  color: var(--jade-deep);
  padding: 1px 8px;
  border-radius: 6px;
  text-decoration: none;
  font-size: 13px;
  margin: 2px 2px;
}
.ext-link:hover { background: var(--jade); color: #fff; }

/* --- Suche --- */
mark { background: #fff3a8; padding: 0 2px; border-radius: 3px; }
input[type="search"] { font-family: inherit; }
