:root {
  --bg: #101418;
  --panel: #171d23;
  --panel-2: #1f2730;
  --text: #f4f7f8;
  --muted: #9ba8b3;
  --accent: #49b848;
  --danger: #d96565;
  --border: rgba(255,255,255,.10);
  --shadow: 0 18px 60px rgba(0,0,0,.35);
}

* {
  box-sizing: border-box;
}

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

body {
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at top left, rgba(73,184,72,.12), transparent 34rem),
    linear-gradient(135deg, #0c1013, var(--bg));
  color: var(--text);
}

.app-shell {
  width: min(1120px, calc(100vw - 24px));
  min-height: 100vh;
  margin: 0 auto;
  padding: 28px 0;
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  gap: 16px;
}

.topbar,
.toolbar,
.editor-card,
.statusbar {
  background: rgba(23,29,35,.86);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.topbar {
  border-radius: 24px;
  padding: 22px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: .14em;
  font-size: .72rem;
  font-weight: 800;
}

h1 {
  margin: 0;
  font-size: clamp(2rem, 5vw, 4.6rem);
  line-height: .92;
  letter-spacing: -.07em;
}

.toolbar {
  border-radius: 20px;
  padding: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

button,
.file-button {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  border-radius: 14px;
  padding: 12px 14px;
  font: inherit;
  font-weight: 750;
  cursor: pointer;
  transition: transform .15s ease, border-color .15s ease, background .15s ease;
}

button:hover,
.file-button:hover {
  transform: translateY(-1px);
  border-color: rgba(73,184,72,.6);
}

button:active,
.file-button:active {
  transform: translateY(0);
}

#pasteBtn {
  background: var(--accent);
  color: #071008;
}

.ghost {
  background: transparent;
}

.danger:hover {
  border-color: rgba(217,101,101,.8);
}

.file-button input {
  display: none;
}

.editor-card {
  border-radius: 24px;
  padding: 14px;
  min-height: 58vh;
}

textarea {
  width: 100%;
  height: 100%;
  min-height: 58vh;
  resize: vertical;
  border: 0;
  outline: 0;
  background: #0b0f12;
  color: var(--text);
  border-radius: 18px;
  padding: 22px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 1rem;
  line-height: 1.65;
  tab-size: 2;
}

textarea::placeholder {
  color: rgba(244,247,248,.35);
}

.statusbar {
  border-radius: 18px;
  padding: 14px 18px;
  display: flex;
  justify-content: space-between;
  gap: 14px;
  color: var(--muted);
  font-size: .92rem;
}

.hidden {
  display: none;
}

@media (max-width: 700px) {
  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .toolbar {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  button,
  .file-button {
    width: 100%;
    text-align: center;
  }

  .statusbar {
    flex-direction: column;
  }
}

.header-actions { display: flex; flex-wrap: wrap; gap: 8px; }
#historyCount { font-size: .8rem; color: var(--muted); margin-left: 4px; }
button:focus-visible, .file-button:focus-within, input:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
textarea:focus-visible { box-shadow: inset 0 0 0 2px var(--accent); }
button:disabled { opacity: .45; cursor: default; }
.file-button { position: relative; }
.file-button input { display: block; position: absolute; width: 1px; height: 1px; opacity: 0; }
.status-message { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
#undoBtn { padding: 5px 9px; font-size: .8rem; }
dialog { background: var(--panel); color: var(--text); border: 1px solid var(--border); border-radius: 22px; padding: 24px; width: min(560px, calc(100vw - 24px)); max-height: 85dvh; overflow: auto; box-shadow: var(--shadow); }
dialog::backdrop { background: rgba(0,0,0,.65); }
.dialog-heading { display: flex; gap: 12px; align-items: center; justify-content: space-between; }
h2 { margin: 0; font-size: 1.4rem; }
.muted { color: var(--muted); font-size: .9rem; line-height: 1.5; }
.setting { display: flex; align-items: center; gap: 10px; margin: 26px 0; }
.setting input { width: 20px; height: 20px; accent-color: var(--accent); }
.backup-tools { display: flex; flex-wrap: wrap; gap: 8px; }
.history-item { display: block; width: 100%; text-align: left; margin-top: 10px; font-weight: 400; }
.history-item strong { display: block; overflow-wrap: anywhere; }
.history-meta { display: block; color: var(--accent); font-size: .8rem; margin: 6px 0; }
.history-preview { display: block; white-space: pre-wrap; overflow-wrap: anywhere; color: var(--muted); font-size: .85rem; }
@media (max-width: 700px) { .header-actions { display: grid; grid-template-columns: 1fr 1fr; } .dialog-heading button { width: auto; } .backup-tools { display: grid; grid-template-columns: 1fr 1fr; } }

/* Keep the longer KIJOBE title and optional help tidy on small screens. */
.topbar > div:first-child { min-width: 0; flex: 1; }
.header-actions { flex-shrink: 0; }
h1 { overflow-wrap: anywhere; }
.statusbar { flex-wrap: wrap; }
.copyright { white-space: nowrap; font-size: .8rem; align-self: center; }
.settings-help { border-top: 1px solid var(--border); margin-top: 12px; }
.settings-help summary { padding: 16px 0; cursor: pointer; font-weight: 750; }
.settings-help summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.help-content > :first-child { margin-top: 0; }
.help-content ul { padding-left: 22px; }
.help-content li { margin-bottom: 10px; }
