/* ================================
   CSS VARIABLES & BASE
================================ */
:root {
  --bg: #ffffff;
  --text: #111111;
  --box: #f7f7f7;
  --border: #e5e5e5;
}

[data-theme="dark"] {
  --bg: #0f0f0f;
  --text: #f1f1f1;
  --box: #1c1c1c;
  --border: #2a2a2a;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
}

/* ================================
   HEADER
================================ */
.site-header {
  position: sticky;
  top: 0;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  z-index: 10;
}

.header-wrap {
  max-width: 1100px;
  margin: auto;
  padding: 14px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.logo {
  font-size: 1.4rem;
  font-weight: 700;
  text-decoration: none;
  color: var(--text);
}

nav {
  display: flex;
  align-items: center;
  gap: 18px;
}

nav a {
  text-decoration: none;
  color: var(--text);
  font-weight: 500;
}

nav #themeToggle {
  padding: 7px 7px 2px 7px;
  border-radius: 50%;
}

/* ================================
   HEADER – MOBILE RESPONSIVE
================================ */

/* Hamburger (hidden on desktop) */
.menu-toggle {
  display: none;
  background: none;
  border: none;
  font-size: 1.4rem;
  cursor: pointer;
}

/* Mobile styles */
@media (max-width: 768px) {

  .header-wrap {
    padding: 12px 16px;
  }

  /* Show hamburger */
  .menu-toggle {
    display: block;
  }

  /* Hide nav initially */
  .site-header nav {
    position: absolute;
    top: 100%;
    right: 12px;
    background: var(--bg);
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    width: 220px;
    border-radius: 14px;
    box-shadow: 0 12px 30px rgba(0,0,0,.15);
    padding: 10px;
    display: none;
  }

  /* Open state */
  .site-header nav.open {
    display: flex;
  }

  .site-header nav a,
  .site-header nav button {
    width: 100%;
    text-align: left;
    padding: 10px 12px;
    border-radius: 10px;
  }

  .site-header nav a:hover,
  .site-header nav button:hover {
    background: var(--box);
  }

  /* Icons aligned */
  #themeToggle,
  .lookup-trigger {
    display: none!important;
    align-items: center;
    gap: 8px;
    padding:10px!important;
    border-radius:10px!important;
    margin-bottom: 10px;
  }
}



[data-theme="dark"] .menu-toggle{
    color:#fff;
}

/* ================================
   FOOTER
================================ */
.site-footer {
  border-top: 1px solid var(--border);
  margin-top: 80px;
  padding: 30px 0;
}

.footer-wrap {
  max-width: 1100px;
  margin: auto;
  padding: 0 20px;
  display: flex;
  justify-content: space-between;
  font-size: 0.9rem;
  color: #777;
}

/* ================================
   HERO
================================ */
.hero {
  text-align: center;
  padding: 90px 20px 50px;
}

.hero h1 {
  font-size: 3rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin-bottom: 12px;
}

.hero-sub {
  font-size: 1.1rem;
  color: #666;
  max-width: 600px;
  margin: 0 auto;
}

[data-theme="dark"] .hero-sub {
  color: #aaa;
}

/* ================================
   EDITOR CARD
================================ */
.editor-section {
  display: flex;
  justify-content: center;
  padding: 0 20px 90px;
}

.editor-card {
  width: 100%;
  max-width: 860px;
  background: var(--bg);
  border-radius: 18px;
  padding: 24px;
  border: 1px solid var(--border);
  box-shadow: 0 25px 50px rgba(0,0,0,0.08);
}

/* ================================
   MARKDOWN TOOLBAR
================================ */
.md-toolbar {
  display: flex;
  gap: 8px;
  padding: 10px;
  background: var(--box);
  border-radius: 12px 12px 0 0;
  border: 1px solid var(--border);
  border-bottom: none;
}

.md-toolbar button {
  background: transparent;
  color: var(--text);
  border: 1px solid #ccc;
  border-radius: 6px;
  padding: 6px 12px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.1s ease;
}

.md-toolbar button:hover {
  background: rgba(0,0,0,0.05);
  transform: translateY(-1px);
}

[data-theme="dark"] .md-toolbar button:hover {
  background: rgba(255,255,255,0.08);
}

/* ================================
   TEXTAREA
================================ */
.editor-card textarea {
  width: 100%;
  min-height: 320px;
  padding: 16px;
  margin-top: 0;
  border-radius: 0 0 14px 14px;
  border: 1px solid var(--border);
  border-top: none;
  font-size: 1.02rem;
  line-height: 1.6;
  resize: vertical;
}

.editor-card textarea:focus {
  outline: none;
  border-color: #000;
}

/* ================================
   OPTIONS ROW
================================ */
.options-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-top: 18px;
}

.options-grid input,
.options-grid select {
  height: 48px;
  padding: 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  font-size: 0.95rem;
}

/* ================================
   PUBLIC TOGGLE
================================ */
.toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-top: 18px;
  padding: 12px 14px;
  background: var(--box);
  border-radius: 12px;
  border: 1px solid var(--border);
}

.toggle input {
  display: none;
}

.toggle-text {
  font-weight: 500;
  font-size: 0.95rem;
}

.slider {
  width: 42px;
  height: 22px;
  background: #ccc;
  border-radius: 50px;
  position: relative;
  cursor: pointer;
  transition: background 0.3s ease;
}

.slider::after {
  content: "";
  width: 18px;
  height: 18px;
  background: #fff;
  border-radius: 50%;
  position: absolute;
  top: 2px;
  left: 2px;
  transition: transform 0.3s ease;
}

.toggle input:checked + .slider {
  background: #000;
}

.toggle input:checked + .slider::after {
  transform: translateX(20px);
}

/* ================================
   PRIMARY CTA BUTTON
================================ */
.primary-btn {
  width: 100%;
  margin-top: 26px;
  padding: 16px;
  font-size: 1.1rem;
  font-weight: 700;
  border-radius: 14px;
  background: #000;
  color: #fff;
  border: none;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.primary-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 25px rgba(0,0,0,0.15);
}

/* ================================
   MARKDOWN RENDERING
================================ */
.markdown h1 { font-size: 2rem; margin-bottom: 12px; }
.markdown h2 { font-size: 1.6rem; margin-top: 20px; }
.markdown p { line-height: 1.7; margin: 10px 0; }
.markdown ul { margin-left: 20px; }
.markdown li { margin-bottom: 6px; }

.markdown pre {
  background: #1e1e1e;
  color: #f8f8f2;
  padding: 16px;
  border-radius: 10px;
  overflow-x: auto;
}

.markdown code {
  background: #eee;
  padding: 2px 6px;
  border-radius: 4px;
}

[data-theme="dark"] .markdown code {
  background: #333;
}

/* ================================
   RESPONSIVE
================================ */
@media (max-width: 768px) {
  .hero h1 {
    font-size: 2.3rem;
  }

  .options-grid {
    grid-template-columns: 1fr;
  }

  .editor-card {
    padding: 18px;
  }
}


/* ================================
   VIEW PAGE
================================ */
.view-container {
  max-width: 860px;
  margin: 60px auto 80px;
  padding: 0 20px;
  animation: pageFadeUp 0.45s ease-out both;
}
@keyframes pageFadeUp {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ACTION BAR */
.view-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 18px;
}

.back-link {
  font-weight: 500;
  text-decoration: none;
  color: #2563eb;
}

.back-link:hover {
  text-decoration: underline;
}

.copy-btn {
  background: var(--box);
  border: 1px solid var(--border);
  padding: 8px 14px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 600;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.copy-btn:active {
  transform: scale(0.96);
}

.copy-btn:hover {
  background: rgba(0,0,0,0.05);
}

[data-theme="dark"] .copy-btn, .copy-btn:hover {
  background: rgba(255,255,255,0.08);
  color:#fff;
}

/* CONTENT CARD */
.view-card {
  background: var(--bg);
  border-radius: 18px;
  border: 1px solid var(--border);
  padding: 28px;
  box-shadow: 0 25px 50px rgba(0,0,0,0.08);
  overflow: hidden;
}

/* MARKDOWN CONTENT POLISH */
.view-card .markdown {
  font-size: 1.05rem;
  line-height: 1.75;
}

.view-card .markdown h1 {
  font-size: 2.1rem;
  margin-bottom: 16px;
}

.view-card .markdown h2 {
  font-size: 1.6rem;
  margin-top: 26px;
}

.view-card .markdown p {
  margin: 12px 0;
}

.view-card .markdown ul {
  margin-left: 22px;
}

.view-card .markdown blockquote {
  border-left: 4px solid #ddd;
  padding-left: 14px;
  color: #555;
  margin: 18px 0;
}
.view-card .markdown img {
  max-width: 100%;
  height: auto;
  display: block;
  margin: 16px auto;
  border-radius: 12px;
   animation: imageReveal 0.4s ease-out both;
}
@keyframes imageReveal {
  from {
    opacity: 0;
    transform: scale(0.97);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}
.view-card .markdown p > img {
  max-width: 100%;
}
@media (hover: hover) {
  .view-card {
    transition: transform 0.25s ease, box-shadow 0.25s ease;
  }

  .view-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 30px 60px rgba(0,0,0,0.12);
  }
}

[data-theme="dark"] .view-card .markdown blockquote {
  border-color: #444;
  color: #aaa;
}

/* CODE BLOCKS */
.view-card .markdown pre {
  background: #1e1e1e;
  color: #f8f8f2;
  padding: 18px;
  border-radius: 12px;
  overflow-x: auto;
  margin: 18px 0;
}

/* INLINE CODE */
.view-card .markdown code {
  background: #eee;
  padding: 3px 6px;
  border-radius: 6px;
  font-size: 0.95rem;
}

[data-theme="dark"] .view-card .markdown code {
  background: #333;
}

/* MOBILE */
@media (max-width: 640px) {
  .view-card {
    padding: 20px;
  }

  .view-actions {
    flex-direction: column;
    gap: 12px;
    align-items: flex-start;
  }
  .view-card .markdown img {
    max-width: 100%;
  }
}

/* ================================
   EXPIRY INFO (VIEW PAGE)
================================ */
.expiry-info {
  font-size: 0.85rem;
  color: #666;
  background: var(--box);
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  white-space: nowrap;
}

.expiry-info strong {
  font-weight: 600;
}

[data-theme="dark"] .expiry-info {
  color: #aaa;
}

/* EXPIRY WARNING STATES */
.expiry-info.expiring-soon {
  background: #fff7ed;
  border-color: #fdba74;
  color: #9a3412;
}

[data-theme="dark"] .expiry-info.expiring-soon {
  background: #431407;
  border-color: #fb923c;
  color: #fdba74;
}
.error-card {
  text-align: center;
  padding: 40px;
}

.error-text {
  color: #dc2626;
  margin-top: 10px;
}

.copy-toast {
  position: fixed;
  bottom: 30px;
  right: 30px;
  background: #000;
  color: #fff;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 0.9rem;
  z-index: 9999;
}
/* ================================
   LOOKUP MODAL – Text Code
================================ */
.lookup-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.65);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

.lookup-modal {
  background: var(--bg);
  border-radius: 18px;
  padding: 38px;
  width: 100%;
  max-width: 600px;
  box-shadow: 0 30px 60px rgba(0,0,0,.4);
  position: relative;
}

.lookup-close {
  position: absolute;
  top: 14px;
  right: 16px;
  background: none;
  border: none;
  font-size: 1.4rem;
  cursor: pointer;
}

.lookup-sub {
  font-size: .9rem;
  color: #888;
  margin-bottom: 18px;
}

.code-inputs {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-bottom: 22px;
}

.code-inputs input {
  width: 56px;
  height: 56px;
  text-align: center;
  font-size: 1.5rem;
  font-weight: 600;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--box);
  outline: none;
  padding: 0;
}

.code-inputs input:focus {
  border-color: #2563eb;
  box-shadow: 0 0 0 2px rgba(37,99,235,.25);
}

.lookup-error {
  color: #dc2626;
  font-size: .85rem;
  margin-top: 10px;
  text-align: center;
}

.primary-btn.full {
  width: 100%;
}
.lookup-trigger{
    background: var(--box);
  border: 1px solid var(--border);
  padding: 8px 10px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 600;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

[data-theme="dark"] .lookup-close{
    color:#fff;
}

[data-theme="dark"] .lookup-trigger{
    background-color:#fff;
}

/* ================================
   LOOKUP MODAL – MOBILE RESPONSIVE
================================ */
@media (max-width: 768px) {

  .lookup-modal {
    padding: 24px;
    max-width: 92%;
    border-radius: 16px;
  }

  .lookup-modal h2 {
    font-size: 1.4rem;
  }

  .lookup-sub {
    font-size: 0.85rem;
  }

  .code-inputs {
    flex-wrap: wrap;
    gap: 10px;
  }

  .code-inputs input {
    width: 44px;
    height: 44px;
    font-size: 1.2rem;
    border-radius: 10px;
  }

  .primary-btn.full {
    padding: 12px;
    font-size: 0.95rem;
  }
}

/* Very small devices (iPhone SE, etc.) */
@media (max-width: 420px) {

  .lookup-modal {
    padding: 20px;
  }

  .code-inputs input {
    width: 40px;
    height: 40px;
    font-size: 1.1rem;
  }
}

/* Pagination */
.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 14px;
  margin-top: 24px;
}

.page-btn {
  text-decoration: none;
  padding: 8px 14px;
  border-radius: 10px;
  background: var(--box);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 600;
}

.page-btn:hover {
  background: rgba(0,0,0,0.05);
}

.page-info {
  font-size: 0.85rem;
  color: #777;
}

[data-theme="dark"] .page-btn:hover {
  background: rgba(255,255,255,0.08);
}

/* ==========================
   PWA BOTTOM NAV
========================== */

.pwa-bottom-nav {
  display: none !important;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 56px;
  background: var(--bg);
  border-top: 1px solid var(--border);
  z-index: 1000;

  display: flex;
  align-items: center;
  justify-content: space-around;
}

/* Buttons */
.nav-btn {
  background: none;
  border: none;
  padding: 8px;
  cursor: pointer;
  color: var(--text);
}

/* SVG icons */
.nav-icon {
  width: 24px;
  height: 24px;
}

/* Space for bottom bar only in PWA */
body.pwa-mode {
  padding-bottom: 56px;
}

/* Show ONLY on mobile screens */
@media (max-width: 768px) {
  .pwa-bottom-nav {
    display: flex !important;
  }

  body {
    padding-bottom: 56px;
  }
}

/* ==========================
   DARK MODE SUPPORT
========================== */

[data-theme="dark"] .pwa-bottom-nav {
  background: #0f0f0f;
  border-top-color: #222;
}

[data-theme="dark"] .nav-btn {
  color: #e5e5e5;
}