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

:root {
  --bg: #111318;
  --panel: #191c22;
  --panel-raised: #1f222a;
  --border: #30343d;
  --border-bright: #444a56;
  --text: #f3f4f6;
  --muted: #9298a5;
  --dim: #656b77;
  --accent: #c6ff55;
  --accent-dark: #101408;
  --danger: #ff7474;
  --success: #75e6a4;
  --mono: 'DM Mono', ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  --sans: 'Manrope', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

* { box-sizing: border-box; }

html { color-scheme: dark; }

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(circle at 82% 0%, rgba(198, 255, 85, 0.07), transparent 30rem),
    var(--bg);
  color: var(--text);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
}

button, textarea, input { font: inherit; }
button { color: inherit; }

.app-shell {
  width: min(1180px, calc(100% - 48px));
  margin: 0 auto;
  padding: 44px 0 32px;
}

.hero {
  display: grid;
  grid-template-columns: minmax(150px, 0.6fr) 2fr;
  gap: 48px;
  align-items: start;
  padding-bottom: 40px;
}

.brand {
  width: fit-content;
  color: var(--text);
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  letter-spacing: -0.03em;
}
.brand span { color: var(--accent); }
.brand:hover { color: var(--accent); }

.hero-copy { max-width: 720px; }
.eyebrow {
  margin: 0 0 12px;
  color: var(--accent);
  font-family: var(--mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

h1 {
  margin: 0;
  font-size: clamp(38px, 6vw, 72px);
  line-height: 0.98;
  letter-spacing: -0.065em;
}
h1 span { color: var(--muted); font-weight: 500; }

.intro {
  max-width: 610px;
  margin: 22px 0 0;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.7;
}

.converter { display: block; }
.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 164px minmax(0, 1fr);
  align-items: stretch;
}
.conversion-options {
  width: 100%;
  margin: 0;
  padding: 0;
  border: 0;
}
.conversion-options legend {
  width: 100%;
  margin-bottom: 7px;
  color: var(--dim);
  font-family: var(--mono);
  font-size: 9px;
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.conversion-options label { position: relative; display: block; margin: 4px 0; cursor: pointer; }
.conversion-options input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.conversion-options span {
  display: block;
  padding: 9px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #15181e;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 10px;
  text-align: center;
  transition: border-color 150ms ease, background 150ms ease, color 150ms ease;
}
.conversion-options label:hover span { border-color: var(--border-bright); color: var(--text); }
.conversion-options input:checked + span {
  border-color: var(--accent);
  background: rgba(198, 255, 85, 0.12);
  color: var(--accent);
  box-shadow: inset 3px 0 0 var(--accent);
}
.conversion-options input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.format-switcher:disabled { opacity: 0.35; pointer-events: none; }

.editor-card {
  display: flex;
  min-height: 500px;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--panel);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.16);
}

.card-header {
  display: flex;
  min-height: 78px;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
}
.card-header > div:first-child {
  display: flex;
  align-items: center;
  gap: 11px;
}
.step {
  color: var(--accent);
  font-family: var(--mono);
  font-size: 10px;
}
h2 { margin: 0; font-size: 14px; font-weight: 700; }

.text-button, .copy-button {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 11px;
  cursor: pointer;
}
.text-button:hover, .copy-button:not(:disabled):hover { color: var(--accent); }
.copy-button:disabled { opacity: 0.35; cursor: not-allowed; }

textarea {
  width: 100%;
  flex: 1;
  resize: none;
  border: 0;
  outline: 0;
  background: transparent;
  color: #dce5ee;
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.75;
  tab-size: 2;
}
textarea::placeholder { color: #555c67; }
.editor-wrap { position: relative; display: flex; flex: 1; min-width: 0; overflow: hidden; }
.highlight-layer, .editor-wrap textarea {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 22px;
  overflow: auto;
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.75;
  tab-size: 2;
  white-space: pre-wrap;
  overflow-wrap: break-word;
}
.highlight-layer {
  z-index: 0;
  pointer-events: none;
  color: #dce5ee;
}
.editor-wrap textarea {
  z-index: 1;
  color: transparent;
  caret-color: #f3f4f6;
}
.editor-wrap textarea::selection { background: rgba(198, 255, 85, 0.28); color: transparent; }
.editor-wrap textarea::-webkit-scrollbar { width: 12px; height: 12px; }
.editor-wrap textarea::-webkit-scrollbar-thumb { border: 4px solid var(--panel); border-radius: 8px; background: var(--border-bright); }
#phpInput { min-height: 360px; }
#phpInput:focus { box-shadow: inset 0 0 0 1px var(--border-bright); }
.token-type { color: #c6ff55; }
.token-number { color: #f7bd6a; }
.token-string { color: #9bd4ff; }
.token-punctuation { color: #a9b0bc; }
.token-key { color: #d9a8ff; }
.token-boolean { color: #f2a1c0; }
.token-null { color: #f2a1c0; }

.input-footer, .status {
  display: flex;
  min-height: 42px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 20px;
  border-top: 1px solid var(--border);
  color: var(--dim);
  font-family: var(--mono);
  font-size: 10px;
}
.shortcut { display: flex; align-items: center; gap: 4px; }
kbd {
  min-width: 19px;
  padding: 2px 5px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--panel-raised);
  text-align: center;
  box-shadow: 0 1px 0 #060708;
}

.actions {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  gap: 9px;
  padding: 24px 14px 16px;
}
.primary-button, .reverse-button, .secondary-button {
  border-radius: 9px;
  cursor: pointer;
  transition: transform 150ms ease, border-color 150ms ease, background 150ms ease;
}
.primary-button {
  display: flex;
  width: 100%;
  min-height: 58px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 10px;
  border: 0;
  background: var(--accent);
  color: var(--accent-dark);
  font-size: 10px;
  font-weight: 800;
  line-height: 1.25;
  text-align: center;
}
.primary-button span:last-child { font-size: 22px; line-height: 1; }
.primary-button:hover { transform: translateY(-2px); background: #d4ff7c; }
.primary-button:active { transform: translateY(0); }
.reverse-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  min-height: 34px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 10px;
}
.reverse-button:hover, .reverse-button[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); }
.reverse-button span:first-child { font-size: 16px; }
.secondary-button {
  border: 1px solid transparent;
  background: transparent;
  color: var(--dim);
  font-family: var(--mono);
  font-size: 10px;
}
.secondary-button:hover { color: var(--text); }

.output-header { flex-wrap: wrap; }
.output-controls { display: flex; align-items: center; gap: 14px; }
.format-switcher {
  display: flex;
  margin: 0;
  padding: 3px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: #14161b;
}
.format-switcher label { position: relative; cursor: pointer; }
.format-switcher input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}
.format-switcher span {
  display: block;
  padding: 6px 9px;
  border-radius: 4px;
  color: var(--dim);
  font-family: var(--mono);
  font-size: 9px;
}
.format-switcher input:checked + span { background: var(--panel-raised); color: var(--text); }
.format-switcher input:focus-visible + span { outline: 2px solid var(--accent); }

.output-wrap { position: relative; display: flex; flex: 1; min-height: 360px; }
.output-editor-wrap { min-height: 360px; }
#jsonOutput { min-height: 360px; }
.empty-mark {
  position: absolute;
  top: 50%;
  left: 50%;
  color: #292d35;
  font-family: var(--mono);
  font-size: 54px;
  transform: translate(-50%, -50%);
  transition: opacity 150ms ease;
}
.output-wrap.has-output .empty-mark { opacity: 0; }
.status { justify-content: flex-start; }
.status-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--dim); }
.status.success { color: var(--success); }
.status.success .status-dot { background: var(--success); box-shadow: 0 0 8px rgba(117, 230, 164, 0.5); }
.status.error { color: var(--danger); }
.status.error .status-dot { background: var(--danger); box-shadow: 0 0 8px rgba(255, 116, 116, 0.45); }

.support-note {
  display: flex;
  gap: 18px;
  align-items: baseline;
  margin: 18px 0 0;
  padding-left: 4px;
  color: var(--dim);
  font-family: var(--mono);
  font-size: 10px;
}
.support-note span { color: var(--accent); text-transform: uppercase; letter-spacing: 0.08em; }
.support-note p { margin: 0; line-height: 1.6; }

footer {
  display: flex;
  justify-content: center;
  gap: 8px;
  padding: 24px;
  color: var(--dim);
  font-family: var(--mono);
  font-size: 10px;
}
footer a { color: var(--muted); text-decoration: none; }
footer a:hover { color: var(--accent); }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 900px) {
  .workspace { grid-template-columns: 1fr; }
  .actions { flex-direction: row; flex-wrap: wrap; padding: 14px 0; }
  .conversion-options { display: flex; flex: 1 0 100%; justify-content: center; }
  .conversion-options legend { display: none; }
  .conversion-options label { flex: 1; max-width: 140px; }
  .primary-button { width: auto; min-height: 44px; flex: 1; flex-direction: row; padding: 10px 18px; }
  .reverse-button { width: auto; min-height: 44px; flex: 1; }
  .secondary-button { flex: 0 0 100%; }
  .primary-button span:last-child { transform: rotate(90deg); }
  .editor-card { min-height: 420px; }
  #phpInput, #jsonOutput, .output-wrap { min-height: 290px; }
}

@media (max-width: 620px) {
  .app-shell { width: min(100% - 28px, 1180px); padding-top: 24px; }
  .hero { grid-template-columns: 1fr; gap: 36px; padding-bottom: 28px; }
  h1 { font-size: clamp(38px, 13vw, 60px); }
  .editor-card { border-radius: 10px; }
  .card-header { align-items: flex-start; }
  .output-header { flex-direction: column; }
  .output-controls { width: 100%; justify-content: space-between; }
  .shortcut { display: none; }
  .support-note { align-items: flex-start; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
.history-panel {
  margin-top: 24px;
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--panel);
}
.history-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.history-header .eyebrow { margin-bottom: 5px; font-size: 9px; }
.history-header h2 { font-size: 15px; }
.history-empty {
  margin: 16px 0 0;
  color: var(--dim);
  font-family: var(--mono);
  font-size: 10px;
  line-height: 1.6;
}
.history-list { display: grid; gap: 8px; margin-top: 16px; }
.history-list:empty { display: none; }
.history-entry {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 14px;
  align-items: center;
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #15181e;
  color: var(--text);
  text-align: left;
  cursor: pointer;
}
.history-entry:hover { border-color: var(--border-bright); background: var(--panel-raised); }
.history-entry:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.history-entry-main { display: grid; gap: 4px; min-width: 0; }
.history-entry-label { color: var(--accent); font-family: var(--mono); font-size: 10px; }
.history-entry-preview {
  overflow: hidden;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.history-entry time { color: var(--dim); font-family: var(--mono); font-size: 9px; white-space: nowrap; }
.history-entry-arrow { color: var(--accent); font-size: 17px; }

@media (max-width: 620px) {
  .history-panel { padding: 16px; }
  .history-entry { grid-template-columns: minmax(0, 1fr) auto; }
  .history-entry time { display: none; }
}
