@import url('https://fonts.googleapis.com/css2?family=DM+Mono:wght@400;500&family=Inter:wght@400;500;600;700;800&display=swap');

:root {
  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --surface-3: #eef2f7;
  --text: #111827;
  --muted: #667085;
  --muted-2: #98a2b3;
  --border: #e4e7ec;
  --border-strong: #d0d5dd;
  --accent: #635bff;
  --accent-hover: #554ce8;
  --accent-soft: #efedff;
  --success: #12b76a;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .04);
  --shadow-md: 0 8px 30px rgba(16, 24, 40, .07);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --sidebar: 272px;
}

* { box-sizing: border-box; }
html { min-height: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 14px;
  line-height: 1.5;
  transition: background .2s ease, color .2s ease;
}
button, input, textarea, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { border: 0; }
a { color: inherit; }

.app-container { min-height: 100vh; display: flex; }
.sidebar {
  position: fixed; inset: 0 auto 0 0; z-index: 100;
  width: var(--sidebar); display: flex; flex-direction: column;
  background: #0b0f19; color: #f8fafc; border-right: 1px solid rgba(255,255,255,.06);
}
.sidebar-header { padding: 22px 18px 18px; }
.brand { display: flex; align-items: center; gap: 11px; text-decoration: none; }
.brand-mark {
  display: grid; place-items: center; width: 40px; height: 40px; border-radius: 11px;
  background: linear-gradient(135deg, #766cff, #4c44d8); color: #fff;
  font: 500 14px 'DM Mono', monospace; box-shadow: 0 8px 24px rgba(99,91,255,.3);
}
.brand strong { display: block; font-size: 16px; letter-spacing: -.02em; }
.brand small { display: block; margin-top: 1px; color: #8f98aa; font-size: 10px; letter-spacing: .04em; text-transform: uppercase; }
.sidebar-content { flex: 1; overflow: auto; padding: 4px 12px 16px; }
.sidebar-section-label { padding: 14px 10px 9px; color: #70798b; font-size: 10px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; }
.feature-group { display: grid; gap: 3px; }
.feature-item {
  width: 100%; display: grid; grid-template-columns: 36px 1fr auto; align-items: center; gap: 9px;
  padding: 9px 9px; border-radius: 10px; color: #9ca6b8; background: transparent; cursor: pointer; text-align: left;
  transition: .18s ease;
}
.feature-item:hover { background: rgba(255,255,255,.05); color: #e8ebf2; }
.feature-item.active { background: rgba(99,91,255,.16); color: #fff; box-shadow: inset 2px 0 0 #776eff; }
.feature-icon { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 9px; background: rgba(255,255,255,.045); font-size: 13px; }
.feature-item.active .feature-icon { background: rgba(99,91,255,.2); color: #a9a4ff; }
.feature-copy strong { display: block; font-size: 12px; font-weight: 600; }
.feature-copy small { display: block; margin-top: 1px; color: #6f7889; font-size: 10px; }
.feature-item.active .feature-copy small { color: #a6aac2; }
kbd { font-family: 'DM Mono', monospace; font-size: 9px; line-height: 20px; min-width: 20px; padding: 0 5px; text-align: center; border: 1px solid currentColor; border-radius: 5px; opacity: .55; }
.sidebar-tip { display: flex; gap: 10px; margin: 22px 5px 0; padding: 12px; border: 1px solid rgba(255,255,255,.07); border-radius: 11px; background: rgba(255,255,255,.025); }
.tip-icon { flex: 0 0 auto; display: grid; place-items: center; width: 27px; height: 27px; border-radius: 7px; background: rgba(99,91,255,.16); color: #a9a4ff; font-size: 11px; }
.sidebar-tip strong { font-size: 10px; }
.sidebar-tip p { margin: 3px 0 0; color: #727b8d; font-size: 9px; line-height: 1.45; }
.sidebar-footer { padding: 14px; border-top: 1px solid rgba(255,255,255,.06); }
.sidebar-footer-links { display: flex; gap: 5px; }
.sidebar-footer a, .sidebar-footer button { flex: 1; padding: 8px 6px; border-radius: 7px; background: transparent; color: #818a9c; font-size: 10px; cursor: pointer; text-decoration: none; }
.sidebar-footer a:hover, .sidebar-footer button:hover { background: rgba(255,255,255,.05); color: #fff; }
.sidebar-footer i { margin-right: 4px; }
.version-pill { display: block; margin-top: 8px; color: #535d70; font: 9px 'DM Mono', monospace; text-align: center; }

.main-content { width: calc(100% - var(--sidebar)); margin-left: var(--sidebar); min-width: 0; }
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 18px clamp(20px, 4vw, 52px); background: rgba(245,247,251,.86); border-bottom: 1px solid rgba(228,231,236,.8); backdrop-filter: blur(14px); }
.topbar-context .eyebrow { display: block; margin-bottom: 2px; color: var(--muted-2); font-size: 9px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; }
.topbar h1 { margin: 0; font-size: 18px; letter-spacing: -.035em; }
.header-actions { display: flex; align-items: center; gap: 7px; }
.status-chip { display: flex; align-items: center; gap: 6px; padding: 7px 10px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); color: var(--muted); font-size: 10px; font-weight: 600; }
.status-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--success); box-shadow: 0 0 0 3px rgba(18,183,106,.1); }
.icon-button { display: grid; place-items: center; width: 34px; height: 34px; padding: 0; border: 1px solid var(--border); border-radius: 9px; background: var(--surface); color: var(--muted); cursor: pointer; transition: .18s ease; }
.icon-button:hover { color: var(--text); border-color: var(--border-strong); box-shadow: var(--shadow-sm); transform: translateY(-1px); }

.workspace-shell { width: min(1200px, calc(100% - 40px)); margin: 0 auto; padding: 28px 0 0; }
.workspace-intro { margin-bottom: 22px; padding: 17px 20px; border: 1px solid var(--border); border-radius: var(--radius-lg); background: linear-gradient(120deg, #fff, #fafaff); box-shadow: var(--shadow-sm); }
.workspace-badge { display: inline-flex; align-items: center; gap: 6px; color: var(--accent); font-size: 9px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.workspace-intro p { margin: 6px 0 0; max-width: 760px; color: var(--muted); font-size: 12px; }
.tool-section { animation: sectionIn .22s ease; }
@keyframes sectionIn { from { opacity: .4; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.section-heading { display: flex; align-items: end; justify-content: space-between; gap: 20px; margin: 0 2px 16px; }
.section-kicker { color: var(--accent); font-size: 9px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }
.section-heading h2 { margin: 3px 0 2px; font-size: 21px; letter-spacing: -.04em; }
.section-heading p { margin: 0; color: var(--muted); font-size: 11px; }
.tool-toolbar { display: flex; align-items: center; gap: 6px; min-height: 42px; padding: 5px; margin-bottom: 10px; overflow-x: auto; border: 1px solid var(--border); border-radius: 11px; background: var(--surface-2); }
.tabs { display: flex; flex-wrap: wrap; gap: 5px; }
.tab-button, .add-tab-button, .preset-select, .secondary-action, .primary-action { border-radius: 8px; cursor: pointer; transition: .16s ease; }
.tab-button { padding: 7px 10px; background: transparent; color: var(--muted); font-size: 11px; }
.tab-button:hover { background: var(--surface-3); color: var(--text); }
.tab-button.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); font-weight: 700; }
.add-tab-button, .primary-action { display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 8px 12px; background: var(--accent); color: #fff; font-size: 11px; font-weight: 700; box-shadow: 0 4px 12px rgba(99,91,255,.16); }
.add-tab-button:hover, .primary-action:hover { background: var(--accent-hover); transform: translateY(-1px); }
.preset-select { min-width: 130px; padding: 8px 28px 8px 10px; border: 1px solid var(--border); background: var(--surface); color: var(--muted); font-size: 11px; }

.json-tab-content { padding: 14px; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); box-shadow: var(--shadow-sm); }
textarea, .json-input { display: block; width: 100%; min-height: 240px; resize: vertical; padding: 14px; margin: 0 0 10px; border: 1px solid var(--border); border-radius: 10px; outline: none; background: #fbfcfe; color: var(--text); font: 12px/1.65 'DM Mono', monospace; box-shadow: inset 0 1px 2px rgba(16,24,40,.02); transition: border .16s ease, box-shadow .16s ease; }
textarea:focus, .json-input:focus { border-color: rgba(99,91,255,.6); box-shadow: 0 0 0 3px rgba(99,91,255,.1); }
textarea::placeholder, input::placeholder { color: #a5adba; }
.search-container, .upload-download-container, .action-row { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; margin: 8px 0; }
.search-input, input[type='text'], input[type='number'], select { min-height: 34px; padding: 7px 10px; border: 1px solid var(--border); border-radius: 8px; outline: none; background: var(--surface); color: var(--text); font-size: 11px; }
.search-input { flex: 1; min-width: 180px; }
input:focus, select:focus { border-color: rgba(99,91,255,.55); box-shadow: 0 0 0 3px rgba(99,91,255,.08); }
.secondary-action, .copy-button { padding: 8px 11px; border: 1px solid var(--border); background: var(--surface); color: var(--muted); font-size: 10px; font-weight: 600; }
.secondary-action:hover, .copy-button:hover { color: var(--text); border-color: var(--border-strong); background: var(--surface-2); }

.preview-section { padding: 16px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); box-shadow: var(--shadow-sm); overflow: auto; word-wrap: normal; max-height: 600px; }
.code-output { margin: 10px 0 0; padding: 16px; overflow: auto; border: 1px solid #252b38; border-radius: 10px; background: #10141c; color: #d9e0ec; font: 12px/1.65 'DM Mono', monospace; box-shadow: 0 8px 24px rgba(16,24,40,.1); }
.code-output.python, .code-output.go, .code-output.typescript { background: #10141c; color: #d9e0ec; }
.code-output .keyword { color: #8f9cff; font-weight: 600; }
.code-output .string { color: #9ed89e; }
.code-output .number { color: #f1c58a; }
.code-output .type { color: #8dd6cc; }
.code-output .comment { color: #778196; font-style: italic; }

.direction-tabs { margin-bottom: 10px; padding: 4px; width: fit-content; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); }
.form-grid { display: grid; grid-template-columns: 130px 1fr; gap: 10px; margin-bottom: 10px; }
.compact-form { grid-template-columns: 130px 220px minmax(180px, 1fr); }
.form-grid label { display: flex; flex-direction: column; gap: 5px; color: var(--muted); font-size: 10px; font-weight: 600; }
.form-grid .wide { min-width: 0; }
.view-toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 10px 0; }
#mock-stats { margin: 0; color: var(--muted); font-size: 10px; }
.segmented-control { display: flex; padding: 3px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface-2); }
.segmented-control label { position: relative; cursor: pointer; }
.segmented-control input { position: absolute; opacity: 0; }
.segmented-control span { display: block; padding: 5px 9px; border-radius: 6px; color: var(--muted); font-size: 10px; }
.segmented-control input:checked + span { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); font-weight: 700; }

.markdown-preview { padding: 16px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); color: var(--text); line-height: 1.7; }
.modal { display: none; position: fixed; inset: 0; z-index: 1000; padding: 20px; background: rgba(15,23,42,.5); backdrop-filter: blur(5px); }
.modal-content { width: min(440px, 100%); margin: 12vh auto; padding: 20px; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); box-shadow: 0 24px 80px rgba(15,23,42,.2); }
.modal-header { display: flex; align-items: start; justify-content: space-between; gap: 15px; }
.modal-header h2 { margin: 3px 0 0; font-size: 18px; letter-spacing: -.03em; }
.shortcut-list { display: grid; gap: 8px; margin-top: 18px; }
.shortcut-list div { display: flex; align-items: center; gap: 5px; padding: 10px 11px; border: 1px solid var(--border); border-radius: 8px; color: var(--muted); font-size: 11px; }
.shortcut-list div span:first-child { flex: 1; color: var(--text); }

.tree-node { margin: 4px 0; padding-left: 20px; position: relative; }
.tree-key { position: relative; display: inline-block; padding: 4px 6px; border-radius: 5px; cursor: pointer; outline: none; transition: .16s ease; }
.tree-key:hover, .tree-key:focus { background: var(--accent-soft); box-shadow: 0 0 0 2px rgba(99,91,255,.12); }
.tree-key::before { content: '\25B6'; display: inline-block; margin-right: 6px; color: #98a2b3; font-size: .7em; transition: transform .2s ease; }
.tree-key.expanded::before { transform: rotate(90deg); color: var(--accent); }
.tree-key .node-info { margin-left: 6px; color: var(--muted-2); font-size: .8em; }
.tree-children { margin-left: 20px; max-height: 1000px; overflow: hidden; opacity: 1; transition: max-height .25s ease, opacity .2s ease; }
.tree-children.collapsed { max-height: 0; opacity: 0; pointer-events: none; }
.type-string { color: #18864b; } .type-number { color: #2874d0; } .type-boolean { color: #8b5cf6; } .type-null { color: #667085; } .type-object { color: #c17d11; } .type-array { color: #db2777; }

.app-footer { display: flex; align-items: center; justify-content: center; gap: 8px; padding: 28px 0 34px; color: var(--muted-2); font-size: 9px; }
.app-footer a { color: var(--muted); text-decoration: none; font-weight: 600; }
.app-footer a:hover { color: var(--accent); }
.footer-separator { opacity: .5; }
.mobile-sidebar-toggle, .mobile-sidebar-close, .sidebar-backdrop { display: none; }

/* Dark theme */
body.dark-mode { --bg: #090c12; --surface: #11161f; --surface-2: #0d121a; --surface-3: #1a202b; --text: #f2f4f7; --muted: #98a2b3; --muted-2: #667085; --border: #242b36; --border-strong: #343d4b; --accent-soft: rgba(99,91,255,.15); }
body.dark-mode .topbar { background: rgba(9,12,18,.84); border-bottom-color: rgba(36,43,54,.8); }
body.dark-mode .workspace-intro { background: linear-gradient(120deg, #11161f, #121523); }
body.dark-mode textarea, body.dark-mode .json-input { background: #0d121a; }
body.dark-mode .preview-section, body.dark-mode .markdown-preview { background: var(--surface); }
body.dark-mode .tree-key:hover, body.dark-mode .tree-key:focus { background: rgba(99,91,255,.13); }
body.dark-mode .type-string { color: #7ee2a8; } body.dark-mode .type-number { color: #79aef5; } body.dark-mode .type-boolean { color: #b7a3ff; }
body.dark-mode .toastui-editor-contents, body.dark-mode .toastui-editor-contents * { color: #e8ecf2; }
body.dark-mode .toastui-editor-defaultUI { border-color: var(--border); background: var(--surface); }
body.dark-mode .tab-button.active, body.dark-mode .segmented-control input:checked + span { background: #1a202b; }

@media (max-width: 900px) {
  :root { --sidebar: 250px; }
  .workspace-shell { width: min(100% - 28px, 1200px); }
  .compact-form { grid-template-columns: 1fr 1fr; }
  .compact-form .wide { grid-column: 1 / -1; }
}
@media (max-width: 720px) {
  .sidebar { transform: translateX(-100%); transition: transform .22s ease; box-shadow: 20px 0 60px rgba(0,0,0,.18); }
  body.sidebar-open .sidebar { transform: translateX(0); }
  body.sidebar-open .sidebar-backdrop { display: block; position: fixed; inset: 0; z-index: 90; background: rgba(15,23,42,.45); backdrop-filter: blur(2px); }
  .main-content { width: 100%; margin-left: 0; }
  .mobile-sidebar-toggle { display: grid; place-items: center; position: fixed; left: 12px; top: 12px; z-index: 80; width: 38px; height: 38px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); color: var(--text); box-shadow: var(--shadow-md); cursor: pointer; }
  .mobile-sidebar-close { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 8px; background: rgba(255,255,255,.06); color: #c5cad4; cursor: pointer; }
  .sidebar-header { display: flex; align-items: center; justify-content: space-between; }
  .topbar { padding: 15px 16px 15px 62px; }
  .status-chip { display: none; }
  .workspace-shell { width: calc(100% - 20px); padding-top: 14px; }
  .workspace-intro { padding: 13px 15px; margin-bottom: 14px; }
  .section-heading { margin-bottom: 11px; }
  .section-heading h2 { font-size: 18px; }
  .section-heading p { max-width: 95%; }
  .json-tab-content { padding: 10px; }
  .compact-form { grid-template-columns: 1fr; }
  .compact-form .wide { grid-column: auto; }
  .view-toggle-row { align-items: flex-start; flex-direction: column; }
  .app-footer { flex-wrap: wrap; padding-bottom: 25px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; }
}
