:root {
  --bg:         #07091a;
  --surface:    #0e1225;
  --surface2:   #141830;
  --border:     #1a2038;
  --border2:    #212840;
  --text:       #dde2f0;
  --text-dim:   #8892a8;
  --text-muted: #454e62;
  --accent:     #5a9cf8;
  --accent-h:   #3f7ee0;
  --err:        #e05050;
  --ok:         #3dba6d;
  --r:          6px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: Arial, sans-serif;
  background:
    radial-gradient(ellipse at top left,    #0d2252 0%, transparent 55%),
    radial-gradient(ellipse at bottom right, #0a1a42 0%, transparent 55%),
    #050810;
  background-attachment: fixed;
  color: var(--text);
  min-height: 100vh;
  font-size: 18px;
  scrollbar-gutter: stable;
}

/* ── App shell ── */
.app-shell {
  min-height: 100vh;
}

/* ── Sidebar — fixed floating card ── */
.sidebar {
  position: fixed;
  top: 16px;
  left: 16px;
  width: 250px;
  background: var(--surface);
  border: 1px solid rgba(90, 156, 248, 0.12);
  border-radius: 14px;
  box-shadow:
    0 0 0 1px rgba(255,255,255,.03) inset,
    0 8px 40px rgba(0,0,0,.55),
    0 2px 8px rgba(0,0,0,.3);
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 32px);
  overflow-y: auto;
  overflow-x: hidden;
  z-index: 100;
  scrollbar-width: thin;
  scrollbar-color: var(--border2) transparent;
}
.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 2px; }

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 14px 13px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.sidebar-close {
  display: none;
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 17px;
  cursor: pointer;
  padding: 3px 7px;
  box-shadow: none;
  line-height: 1;
  border-radius: var(--r);
}
.sidebar-close:hover { background: var(--border2); color: var(--text); transform: none; box-shadow: none; }

.sidebar-nav {
  padding: 8px 0 14px;
  flex: 1;
}

.nav-group { margin-bottom: 2px; }

.nav-group + .nav-group {
  border-top: 1px solid var(--border);
  margin-top: 6px;
  padding-top: 6px;
}

.nav-group-label {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 9px 14px 6px;
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
}

.nav-group-icon { font-size: 17px; line-height: 1; opacity: .7; }

.nav-item {
  display: block;
  padding: 8px 12px;
  margin: 2px 8px;
  font-size: 17px;
  color: var(--text-dim);
  text-decoration: none;
  border-radius: 8px;
  transition: color .18s, background .18s, box-shadow .18s, transform .12s;
}
.nav-item:hover {
  color: var(--text);
  background: rgba(255,255,255,.05);
  transform: translateX(2px);
}
.nav-item.active {
  color: #fff;
  background: linear-gradient(90deg, #5a9cf8 0%, #4080e8 100%);
  box-shadow: 0 2px 12px rgba(90, 156, 248, .4);
  font-weight: 500;
  transform: none;
}

/* ── Logo ── */
.logo {
  font-size: 24px;
  font-weight: bold;
  color: var(--text);
  white-space: nowrap;
  letter-spacing: .3px;
  text-decoration: none;
  line-height: 1;
}
.logo span { color: var(--accent); }

/* Accent stripe at top of the floating sidebar card */
.sidebar::before {
  content: '';
  display: block;
  height: 3px;
  background: linear-gradient(90deg, var(--accent) 0%, #7eb8ff 60%, transparent 100%);
  border-radius: 14px 14px 0 0;
  flex-shrink: 0;
}

/* ── Page wrap (right side) ── */
.page-wrap {
  margin-left: 282px; /* 16px gap + 250px sidebar + 16px right gap */
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── Topbar (mobile hamburger bar) ── */
.topbar {
  display: none;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  background: linear-gradient(90deg, #0c1228 0%, #0f1530 100%);
  border-bottom: 1px solid rgba(90, 156, 248, 0.14);
  box-shadow: 0 2px 20px rgba(0,0,0,.5);
  position: sticky;
  top: 0;
  z-index: 50;
  flex-shrink: 0;
}

.hamburger {
  background: none;
  border: none;
  color: var(--text);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  padding: 2px 6px;
  box-shadow: none;
  border-radius: var(--r);
  flex-shrink: 0;
}
.hamburger:hover { background: var(--surface2); transform: none; box-shadow: none; }

.topbar-title {
  font-size: 17px;
  font-weight: bold;
  color: var(--text);
}

/* ── Sidebar overlay (mobile backdrop) ── */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.55);
  z-index: 90;
}
.sidebar-overlay.on { display: block; }

/* ── Main ── */
main {
  flex: 1;
  padding: 24px;
  max-width: 1280px;
  width: 100%;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

#placeholder {
  text-align: center;
  padding: 100px 20px;
  color: var(--text-muted);
  font-size: 16px;
  line-height: 1.8;
}
#placeholder strong { color: var(--text-dim); display: block; font-size: 18px; margin-bottom: 8px; }

.tool-section { display: none; }
.tool-section.active { display: flex; flex-direction: column; gap: 14px; }

/* ── Controls bar ── */
.controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* ── Buttons ── */
button {
  background: linear-gradient(135deg, #5a9cf8 0%, #3f7ee0 100%);
  color: #fff;
  border: none;
  border-radius: var(--r);
  padding: 8px 18px;
  font-family: Arial, sans-serif;
  font-size: 17px;
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s, box-shadow .15s, transform .1s;
  box-shadow: 0 2px 8px rgba(90, 156, 248, 0.2);
}
button:hover {
  background: linear-gradient(135deg, #6aaafb 0%, #5a9cf8 100%);
  box-shadow: 0 4px 16px rgba(90, 156, 248, 0.3);
  transform: translateY(-1px);
}
button:active { transform: translateY(0); }
button.ghost {
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--border2);
  box-shadow: none;
}
button.ghost:hover {
  background: var(--border);
  border-color: rgba(90, 156, 248, 0.3);
  box-shadow: none;
  transform: none;
}
button.mini {
  font-size: 15px;
  padding: 3px 10px;
  background: var(--surface2);
  color: var(--text-dim);
  border: 1px solid var(--border2);
  box-shadow: none;
}
button.mini:hover {
  color: var(--text);
  background: var(--border2);
  box-shadow: none;
  transform: none;
}
button.ok { background: #1a4a28; color: var(--ok); border: 1px solid #2a6a3a; pointer-events: none; box-shadow: none; }

/* ── Format select ── */
select.fmt {
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--border2);
  border-radius: var(--r);
  padding: 7px 26px 7px 10px;
  font-family: Arial, sans-serif;
  font-size: 17px;
  cursor: pointer;
  outline: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%238892a8'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  transition: border-color .15s;
}
select.fmt:hover { border-color: rgba(90, 156, 248, 0.3); }
select.fmt option { background: #141830; }

.arrow { color: var(--text-muted); font-size: 19px; }

/* ── Panels ── */
.panels {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  align-items: stretch;
}
.panel {
  display: flex;
  flex-direction: column;
  gap: 7px;
}
.panel-head {
  font-size: 15px;
  color: var(--text-dim);
  display: flex;
  align-items: center;
  justify-content: space-between;
  text-transform: uppercase;
  letter-spacing: .4px;
}

/* ── Textarea ── */
textarea {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border2);
  border-radius: var(--r);
  padding: 13px;
  font-family: 'Courier New', monospace;
  font-size: 13.5px;
  resize: vertical;
  flex: 1;
  height: 0;
  min-height: 360px;
  width: 100%;
  outline: none;
  line-height: 1.6;
  tab-size: 2;
  transition: border-color .15s, box-shadow .15s;
}
textarea:focus {
  border-color: rgba(90, 156, 248, 0.4);
  box-shadow: 0 0 0 3px rgba(90, 156, 248, 0.07);
}
textarea[readonly] { color: var(--text-dim); }

/* ── Input fields ── */
input[type="text"],
input[type="number"],
input[type="datetime-local"] {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border2);
  border-radius: var(--r);
  padding: 9px 12px;
  font-family: Arial, sans-serif;
  font-size: 17px;
  width: 100%;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
input:focus {
  border-color: rgba(90, 156, 248, 0.4);
  box-shadow: 0 0 0 3px rgba(90, 156, 248, 0.07);
}

/* ── Error / info ── */
.err {
  font-size: 16px;
  color: var(--err);
  padding: 6px 10px;
  background: rgba(224,80,80,.07);
  border: 1px solid rgba(224,80,80,.2);
  border-radius: var(--r);
  display: none;
}
.err.on { display: block; }

/* ── Tabs ── */
.tab-bar {
  display: flex;
  border-bottom: 1px solid var(--border2);
}
.tab-btn {
  background: none;
  color: var(--text-dim);
  border: none;
  border-bottom: 2px solid transparent;
  padding: 8px 16px;
  font-size: 16px;
  cursor: pointer;
  border-radius: 0;
  margin-bottom: -1px;
  box-shadow: none;
  transition: color .15s;
}
.tab-btn:hover { color: var(--text); background: none; box-shadow: none; transform: none; }
.tab-btn.active { color: var(--text); border-bottom-color: var(--accent); }
.tab-pane { display: none; }
.tab-pane.active { display: flex; flex-direction: column; gap: 14px; }

/* ── Markdown preview ── */
.preview-pane {
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: var(--r);
  padding: 16px 20px;
  min-height: 360px;
  overflow-y: auto;
  line-height: 1.7;
  font-size: 17.5px;
}
.preview-pane h1,.preview-pane h2,.preview-pane h3,
.preview-pane h4,.preview-pane h5,.preview-pane h6 { margin: 1em 0 .4em; line-height: 1.3; }
.preview-pane p { margin: .5em 0; }
.preview-pane code { background: var(--surface2); padding: 2px 5px; border-radius: 3px; font-size: 15px; }
.preview-pane pre { background: var(--surface2); padding: 12px; border-radius: var(--r); overflow-x: auto; margin: .5em 0; }
.preview-pane pre code { background: none; padding: 0; }
.preview-pane a { color: var(--accent); }
.preview-pane ul,.preview-pane ol { padding-left: 20px; margin: .5em 0; }
.preview-pane blockquote { border-left: 3px solid var(--border2); padding-left: 12px; color: var(--text-dim); margin: .5em 0; }
.preview-pane table { border-collapse: collapse; width: 100%; margin: .5em 0; font-size: 16px; }
.preview-pane th,.preview-pane td { border: 1px solid var(--border2); padding: 6px 10px; text-align: left; }
.preview-pane th { background: var(--surface2); }
.preview-pane hr { border: none; border-top: 1px solid var(--border2); margin: 1em 0; }

/* ── Timestamp tool ── */
.ts-grid {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 14px;
  align-items: center;
}
.ts-col { display: flex; flex-direction: column; gap: 8px; }
.ts-mid { color: var(--text-muted); font-size: 25px; text-align: center; }
.ts-label { font-size: 14px; color: var(--text-dim); text-transform: uppercase; letter-spacing: .4px; }
.ts-human-row { display: flex; gap: 6px; align-items: center; }
.ts-human-row input[type="text"] { flex: 1; }
.ts-cal-btn { padding: 8px 10px; font-size: 17px; line-height: 1; }

.ts-result {
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: var(--r);
  overflow: hidden;
}
.ts-row {
  display: flex;
  align-items: baseline;
  gap: 12px;
  padding: 9px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 17px;
}
.ts-row:last-child { border-bottom: none; }
.ts-rl { color: var(--text-dim); min-width: 160px; font-size: 16px; flex-shrink: 0; }
.ts-rv { font-family: 'Courier New', monospace; font-size: 16.5px; }

.ts-now {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 16px;
  color: var(--text-dim);
  flex-wrap: wrap;
}
#ts-now-val { font-family: 'Courier New', monospace; color: var(--text); }

/* ── Base64 file ── */
.file-card {
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: var(--r);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.file-card-title {
  font-size: 15px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: .4px;
}
.drop-zone {
  border: 2px dashed var(--border2);
  border-radius: var(--r);
  padding: 28px;
  text-align: center;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 17px;
  transition: border-color .15s, color .15s, box-shadow .15s;
}
.drop-zone:hover, .drop-zone.over {
  border-color: var(--accent);
  color: var(--text);
  box-shadow: 0 0 0 3px rgba(90, 156, 248, 0.07);
}
.drop-zone input[type="file"] { display: none; }
.drop-zone .dz-hint { font-size: 14px; margin-top: 4px; color: var(--text-muted); }

/* ── Key generator ── */
.kg-cb {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 16px;
  color: var(--text-dim);
  cursor: pointer;
  user-select: none;
}
.kg-cb input[type="checkbox"] { accent-color: var(--accent); width: 15px; height: 15px; cursor: pointer; }

/* ── Escape tool ── */
.escape-types { display: flex; gap: 6px; flex-wrap: wrap; }
.esc-type-btn {
  background: var(--surface2);
  color: var(--text-dim);
  border: 1px solid var(--border2);
  border-radius: 20px;
  padding: 5px 14px;
  font-size: 16px;
  cursor: pointer;
  box-shadow: none;
  transition: color .15s, background .15s, border-color .15s;
}
.esc-type-btn:hover { color: var(--text); background: var(--border2); transform: none; box-shadow: none; }
.esc-type-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); box-shadow: 0 2px 8px rgba(90,156,248,.25); }

/* ── Footer ── */
footer {
  margin-top: auto;
  margin-left: -282px;
  width: calc(100% + 282px);
  border-top: 1px solid var(--border);
  padding: 12px 24px;
  text-align: center;
  font-size: 14px;
  color: var(--text-muted);
  background: linear-gradient(90deg, #0c1228 0%, #0f1530 100%);
}

/* ── Responsive ── */
@media (max-width: 720px) {
  .panels { grid-template-columns: 1fr; }
  .ts-grid { grid-template-columns: 1fr; }
  .ts-mid { display: none; }

  /* Sidebar slides off-screen on mobile */
  .sidebar {
    top: 0;
    left: 0;
    max-height: 100vh;
    border-radius: 0 14px 14px 0;
    transform: translateX(-100%);
    transition: transform .28s cubic-bezier(.4,0,.2,1);
    box-shadow: 6px 0 32px rgba(0,0,0,.6);
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-close { display: block; }
  .topbar { display: flex; }
  .page-wrap { margin-left: 0; }
  footer { margin-left: 0; width: auto; }
}
