/* ============================================================== *
 *  Kachelwerk – shared tokens + base + project overview
 *  Aesthetic: dark technical workbench, signal-amber accent,
 *  Bricolage Grotesque (display) + JetBrains Mono (technical).
 * ============================================================== */

:root {
  --bg:          #0a0c11;
  --bg-soft:     #0d1017;
  --panel:       #11151e;
  --panel-2:     #151b26;
  --surface:     #161d2a;
  --surface-2:   #1d2634;
  --line:        #232c3c;
  --line-soft:   #1a212d;
  --line-strong: #303d52;

  --text:        #eef1f7;
  --text-dim:    #9aa7bd;
  --text-faint:  #5d6b82;

  --accent:      #ffb84d;
  --accent-deep: #f5972f;
  --accent-ink:  #1c1304;
  --green:       #46e0a0;
  --blue:        #74a8ff;
  --cyan:        #43c9e8;
  --violet:      #b58cff;
  --red:         #ff6470;
  --rose:        #f43f5e;

  --radius:    14px;
  --radius-sm: 9px;
  --shadow:    0 22px 48px -22px rgba(0,0,0,.75);
  --shadow-sm: 0 8px 22px -12px rgba(0,0,0,.6);

  --font-display: "Bricolage Grotesque", ui-sans-serif, system-ui, sans-serif;
  --font-mono:    "JetBrains Mono", ui-monospace, "SFMono-Regular", monospace;
}

* { box-sizing: border-box; }

/* the [hidden] attribute must always win over author display rules */
[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-display);
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; }

/* film-grain / atmosphere overlay -------------------------------- */
.grain {
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background:
    radial-gradient(1100px 620px at 78% -8%, rgba(255,184,77,.10), transparent 60%),
    radial-gradient(900px 600px at 4% 108%, rgba(116,168,255,.08), transparent 55%);
  opacity: .9;
}
.overview::before {
  content: ""; position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background-image: radial-gradient(rgba(255,255,255,.035) 1px, transparent 1px);
  background-size: 26px 26px;
  mask-image: radial-gradient(120% 100% at 50% 0%, #000 35%, transparent 92%);
}

/* ---- top bar --------------------------------------------------- */
.topbar {
  position: relative; z-index: 2;
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 34px;
  border-bottom: 1px solid var(--line-soft);
}
.brand { display: inline-flex; align-items: center; gap: 12px; }
.brand-mark { color: var(--accent); display: inline-flex; filter: drop-shadow(0 0 10px rgba(255,184,77,.35)); }
.brand-name {
  font-weight: 700; font-size: 19px; letter-spacing: -.02em;
}
.topbar-meta {
  font-family: var(--font-mono); font-size: 11.5px; letter-spacing: .14em;
  text-transform: uppercase; color: var(--text-faint);
}

/* ---- shell / hero ---------------------------------------------- */
.shell { position: relative; z-index: 1; max-width: 1180px; margin: 0 auto; padding: 56px 34px 90px; }

.hero { max-width: 680px; margin-bottom: 52px; }
.eyebrow {
  font-family: var(--font-mono); font-size: 12px; letter-spacing: .2em; text-transform: uppercase;
  color: var(--accent); margin: 0 0 18px;
}
.hero-title {
  font-size: clamp(48px, 9vw, 104px);
  line-height: .92; letter-spacing: -.045em; font-weight: 800; margin: 0;
}
.hero-sub {
  margin: 22px 0 30px; max-width: 540px;
  color: var(--text-dim); font-size: 17px; line-height: 1.55; font-weight: 300;
}

/* ---- buttons --------------------------------------------------- */
.btn {
  --bg-btn: var(--surface);
  display: inline-flex; align-items: center; vertical-align: middle; gap: 9px;
  padding: 10px 16px; border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong); background: var(--bg-btn);
  color: var(--text); font-size: 14px; font-weight: 500; cursor: pointer;
  transition: transform .12s ease, border-color .15s ease, background .15s ease, box-shadow .15s ease;
}
.btn:hover { transform: translateY(-1px); border-color: var(--text-faint); }
.btn:active { transform: translateY(0); }
.btn-accent {
  background: linear-gradient(180deg, var(--accent), var(--accent-deep));
  color: var(--accent-ink); border-color: transparent; font-weight: 600;
  box-shadow: 0 10px 26px -12px rgba(255,160,60,.7);
}
.btn-accent:hover { border-color: transparent; box-shadow: 0 14px 30px -12px rgba(255,160,60,.85); }
.btn-ghost { background: transparent; border-color: var(--line); color: var(--text-dim); }
.btn-ghost:hover { color: var(--text); }
.btn-danger { color: var(--red); border-color: color-mix(in srgb, var(--red) 35%, var(--line)); background: transparent; }
.btn-danger:hover { background: color-mix(in srgb, var(--red) 14%, transparent); }
.btn-lg { padding: 14px 22px; font-size: 16px; border-radius: 11px; }
.btn-icon { padding: 9px; }
.plus { font-size: 19px; line-height: 0; margin-top: -2px; }

/* ---- project grid ---------------------------------------------- */
.projects {
  display: grid; gap: 18px;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
}
.loading { color: var(--text-faint); font-family: var(--font-mono); font-size: 13px; padding: 30px 4px; }

.project-card {
  position: relative; display: flex; flex-direction: column;
  padding: 22px; min-height: 168px;
  background:
     linear-gradient(180deg, rgba(255,255,255,.02), transparent 40%),
     var(--panel);
  border: 1px solid var(--line); border-radius: var(--radius);
  cursor: pointer; overflow: hidden;
  transition: transform .16s ease, border-color .16s ease, box-shadow .16s ease;
}
.project-card::after {
  content: ""; position: absolute; left: 0; right: 0; top: 0; height: 2px;
  background: linear-gradient(90deg, var(--accent), transparent 60%);
  transform: scaleX(0); transform-origin: left; transition: transform .25s ease;
}
.project-card:hover { transform: translateY(-3px); border-color: var(--line-strong); box-shadow: var(--shadow); }
.project-card:hover::after { transform: scaleX(1); }
.project-card.opening {
  pointer-events: none;
  border-color: var(--accent);
  box-shadow: var(--shadow);
  opacity: .72;
}
.project-card.opening::after { transform: scaleX(1); }

.project-name {
  font-size: 22px; font-weight: 600; letter-spacing: -.02em; margin: 4px 0 0;
  padding-right: 96px;        /* clear the action icons (top-right) so the name wraps instead of sliding under them */
  overflow-wrap: anywhere;    /* break overly long unbroken names too */
}
.project-meta {
  margin-top: auto; padding-top: 18px;
  display: flex; align-items: center; gap: 14px;
  font-family: var(--font-mono); font-size: 11.5px; color: var(--text-faint);
}
.project-meta .dot { width: 4px; height: 4px; border-radius: 50%; background: var(--text-faint); }
.project-id {
  font-family: var(--font-mono); font-size: 10.5px; color: var(--text-faint);
  letter-spacing: .04em; opacity: .7;
}
.card-actions {
  position: absolute; top: 14px; right: 14px; display: flex; gap: 6px;
  opacity: 0; transform: translateY(-4px); transition: .16s ease;
}
.project-card:hover .card-actions { opacity: 1; transform: none; }
.icon-btn {
  display: inline-grid; place-items: center; width: 30px; height: 30px;
  border-radius: 8px; border: 1px solid var(--line); background: var(--surface);
  color: var(--text-dim); cursor: pointer; transition: .14s ease;
}
.icon-btn:hover { color: var(--text); border-color: var(--text-faint); }
.icon-btn.danger:hover { color: var(--red); border-color: var(--red); }

/* empty state */
.empty {
  grid-column: 1 / -1; text-align: center; padding: 70px 20px;
  border: 1px dashed var(--line); border-radius: var(--radius); color: var(--text-faint);
}
.empty h3 { font-size: 26px; color: var(--text-dim); font-weight: 500; margin: 0 0 8px; letter-spacing: -.02em; }

/* ---- dialog ---------------------------------------------------- */
.dialog { border: none; padding: 0; background: transparent; color: var(--text); }
.dialog::backdrop { background: rgba(5,7,11,.66); backdrop-filter: blur(4px); }
.dialog-card {
  width: min(440px, 92vw);
  background: var(--panel); border: 1px solid var(--line-strong);
  border-radius: var(--radius); padding: 26px; box-shadow: var(--shadow);
}
.dialog-title { margin: 0 0 6px; font-size: 24px; font-weight: 600; letter-spacing: -.02em; }
.dialog-sub { margin: 0 0 20px; color: var(--text-dim); font-size: 14px; font-weight: 300; line-height: 1.5; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; }

/* ---- schedule overview ----------------------------------------- */
.dialog-schedule-overview .schedule-overview-card {
  width: min(920px, 94vw);
  max-height: 86vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.schedule-overview-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}
.schedule-overview-head .eyebrow { margin-bottom: 8px; }
.schedule-overview-body {
  min-height: 180px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg-soft);
}
.schedule-table-wrap { overflow-x: auto; }
.schedule-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 660px;
}
.schedule-table th,
.schedule-table td {
  padding: 15px 16px;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid var(--line-soft);
}
.schedule-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--panel);
  color: var(--text-faint);
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: .14em;
  text-transform: uppercase;
}
.schedule-table tr:last-child td { border-bottom: 0; }
.schedule-table tr.is-active td {
  background: color-mix(in srgb, var(--green) 9%, transparent);
}
.schedule-table tr.is-active .schedule-workflow {
  color: color-mix(in srgb, var(--green) 36%, var(--text));
}
.schedule-workflow {
  display: inline-block;
  color: var(--text);
  font-size: 17px;
  font-weight: 600;
  overflow-wrap: anywhere;
}
.schedule-workflow:hover { color: var(--accent); }
.schedule-project,
.schedule-triggers {
  margin-top: 5px;
  color: var(--text-faint);
  font-family: var(--font-mono);
  font-size: 11px;
  line-height: 1.45;
}
.schedule-triggers { color: var(--text-dim); }
.schedule-runs {
  display: flex;
  flex-direction: column;
  gap: 6px;
  color: var(--text-dim);
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.45;
}
.schedule-empty {
  border: 0;
  border-radius: 0;
  padding: 54px 20px;
}

@media (max-width: 720px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
    gap: 14px;
  }
  .hero .btn-lg {
    width: 100%;
    justify-content: center;
    margin-left: 0 !important;
    margin-top: 10px;
  }
  .schedule-table { min-width: 0; }
  .schedule-table thead { display: none; }
  .schedule-table,
  .schedule-table tbody,
  .schedule-table tr,
  .schedule-table td { display: block; width: 100%; }
  .schedule-table tr { border-bottom: 1px solid var(--line-soft); }
  .schedule-table tr:last-child { border-bottom: 0; }
  .schedule-table td { border-bottom: 0; padding: 14px; }
  .schedule-table td + td { padding-top: 0; }
}

.field { display: block; }
.field-label {
  display: block; font-family: var(--font-mono); font-size: 11px; letter-spacing: .12em;
  text-transform: uppercase; color: var(--text-faint); margin-bottom: 8px;
}
.input, .textarea {
  width: 100%; background: var(--bg-soft); color: var(--text);
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  padding: 12px 14px; font-family: var(--font-display); font-size: 15px; outline: none;
  transition: border-color .14s ease, box-shadow .14s ease;
}
.input:focus, .textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent);
}

/* ---- toast ----------------------------------------------------- */
.toast {
  position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%) translateY(20px);
  z-index: 50; padding: 12px 18px; border-radius: 11px;
  background: var(--panel-2); border: 1px solid var(--line-strong);
  color: var(--text); font-size: 14px; box-shadow: var(--shadow);
  opacity: 0; pointer-events: none; transition: .22s ease;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.error { border-color: var(--red); }
.toast.ok { border-color: color-mix(in srgb, var(--green) 50%, var(--line-strong)); }

/* ---- language switch (DE / EN), shared across pages ---------------- */
.lang-switch {
  display: inline-flex; align-items: center; gap: 0;
  border: 1px solid var(--line); border-radius: 9px;
  background: var(--panel); overflow: hidden;
}
.lang-switch .lang-opt {
  appearance: none; border: 0; background: transparent; cursor: pointer;
  font: 600 12px/1 'JetBrains Mono', monospace; letter-spacing: .04em;
  color: var(--text-dim); padding: 7px 10px; transition: .15s ease;
}
.lang-switch .lang-opt:hover { color: var(--text); }
.lang-switch .lang-opt.is-on { background: var(--surface-2); color: var(--text); }
.lang-switch .lang-opt + .lang-opt { border-left: 1px solid var(--line); }

/* -- prompt dialog -------------------------------------------------------- */
.dialog-prompt .dialog-card { width: min(620px, 92vw); position: relative; }
.dialog-prompt .dialog-title { padding-right: 38px; }
.prompt-close { position: absolute; top: 18px; right: 18px; }
.prompt-input-wrap { position: relative; }
.prompt-input-wrap .textarea { width: 100%; padding-right: 2.8rem; }
.mic-btn { position: absolute; top: .5rem; right: .5rem; }
.mic-btn.listening { color: #e5484d; animation: micpulse 1.2s ease-in-out infinite; }
@keyframes micpulse { 0%,100% { opacity: 1 } 50% { opacity: .4 } }
.prompt-log { margin-top: .7rem; max-height: 220px; overflow: auto; white-space: pre-wrap;
  font-family: 'JetBrains Mono', monospace; font-size: .78rem; line-height: 1.5;
  background: rgba(0,0,0,.25); border-radius: 10px; padding: .6rem .7rem; }
.prompt-error { margin-top: .6rem; color: #e5484d; font-size: .85rem; }

/* prompt history dropdown */
.prompt-history { margin: 0 0 .7rem; }
.prompt-history-toggle { display: inline-flex; align-items: center; gap: .4rem;
  background: none; border: 0; cursor: pointer; color: inherit; opacity: .75;
  font: inherit; font-size: .82rem; padding: .15rem 0; }
.prompt-history-toggle:hover { opacity: 1; }
.prompt-history-toggle .phi-chevron { transition: transform .15s ease; }
.prompt-history.open .prompt-history-toggle .phi-chevron { transform: rotate(180deg); }
.prompt-history-list { margin-top: .4rem; max-height: 200px; overflow: auto;
  display: flex; flex-direction: column; gap: .3rem; }
.prompt-history-item { display: flex; align-items: stretch; gap: .2rem;
  border-radius: 8px; border: 1px solid transparent; color: inherit; }
.prompt-history-item.is-applied  { background: rgba(70, 196, 106, .12); border-color: rgba(70, 196, 106, .30); }
.prompt-history-item.is-rejected { background: rgba(229, 72, 77, .10);  border-color: rgba(229, 72, 77, .28); }
.prompt-history-item .phi-main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column;
  gap: .15rem; text-align: left; cursor: pointer; font: inherit; color: inherit;
  background: none; border: 0; padding: .4rem .55rem; border-radius: 8px; }
.prompt-history-item .phi-main:hover { filter: brightness(1.15); }
.prompt-history-item .phi-when { font-size: .72rem; opacity: .7; }
.prompt-history-item .phi-text { font-size: .82rem; line-height: 1.35;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.prompt-history-item .phi-del { flex: 0 0 auto; display: grid; place-items: center; width: 30px;
  background: none; border: 0; color: inherit; opacity: .45; cursor: pointer; border-radius: 8px; }
.prompt-history-item .phi-del:hover { opacity: 1; color: var(--red); }
.prompt-history-item .phi-del:disabled { opacity: .25; cursor: default; }

/* ---- phone layout (≤600px) ------------------------------------- */
@media (max-width: 600px) {
  .shell { padding: 34px 18px 70px; }
  .topbar { padding: 16px 18px; }
  .hero { margin-bottom: 36px; }
  .projects { grid-template-columns: 1fr; gap: 14px; }
  .project-card { min-height: 150px; padding: 18px; }
  .project-name { padding-right: 80px; }
  .card-actions { opacity: 1; transform: none; }
}
