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

html, body {
  height: 100%;
  overflow: hidden;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: radial-gradient(circle at top left, rgba(96, 120, 255, 0.12), transparent 28%),
    radial-gradient(circle at bottom right, rgba(95, 125, 255, 0.08), transparent 28%),
    #080a13;
  color: #e0e0e0;
  display: flex;
  align-items: stretch;
}

/* ---- Layout ---- */
.container {
  display: grid;
  grid-template-columns: 300px 1fr;
  width: 100%;
  height: 100vh;
}

/* ---- Sidebar ---- */
.panel {
  background: rgba(12, 16, 34, 0.98);
  border-right: 1px solid rgba(70, 80, 150, 0.18);
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

.panel-header {
  padding: 24px 20px 18px;
  border-bottom: 1px solid rgba(71, 88, 197, 0.2);
  background: linear-gradient(180deg, rgba(30, 37, 74, 0.98), rgba(11, 14, 30, 0.98));
  flex-shrink: 0;
}

.brand-title {
  display: flex;
  align-items: center;
  gap: 18px;
}

.brand-logo {
  width: 96px;
  height: auto;
  min-width: 96px;
  border-radius: 18px;
  padding: 8px;
  filter: drop-shadow(0 0 18px rgba(95, 125, 255, 0.35));
}

.brand-label {
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: #8ea0ff;
  margin-bottom: 4px;
}

.panel-header h1 {
  font-size: 22px;
  font-weight: 700;
  color: #ffffff;
  letter-spacing: -0.3px;
  margin: 0;
}

.tool-tagline {
  margin: 6px 0 0;
  font-size: 12px;
  color: #b5bfff;
}

.panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  scrollbar-width: thin;
  scrollbar-color: #2a2a2a transparent;
}

.panel-body::-webkit-scrollbar { width: 4px; }
.panel-body::-webkit-scrollbar-track { background: transparent; }
.panel-body::-webkit-scrollbar-thumb { background: #2a2a2a; border-radius: 4px; }

/* ---- Section title ---- */
.section-title {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: #444;
  margin-bottom: 8px;
}

/* ---- Pattern input ---- */
.pattern-wrap {
  display: flex;
  align-items: center;
  gap: 0;
  background: #111420;
  border: 1px solid #1e2340;
  border-radius: 8px;
  overflow: hidden;
  transition: border-color .15s;
}
.pattern-wrap:focus-within { border-color: #3a4070; }

.slash {
  padding: 0 8px;
  color: #5f7dff;
  font-family: monospace;
  font-size: 16px;
  font-weight: 700;
  user-select: none;
  flex-shrink: 0;
}

.pattern-wrap input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: #e0e0e0;
  font-family: 'Menlo', 'Monaco', 'Courier New', monospace;
  font-size: 13px;
  padding: 8px 0;
  min-width: 0;
}

.flags-inline {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 0 8px 0 4px;
  flex-shrink: 0;
}

.flags-inline label {
  display: flex;
  align-items: center;
  cursor: pointer;
  padding: 3px 5px;
  border-radius: 4px;
  transition: background .15s;
}
.flags-inline label:hover { background: rgba(95,125,255,0.1); }
.flags-inline input[type=checkbox] { display: none; }
.flags-inline span {
  font-family: monospace;
  font-size: 12px;
  color: #444;
  font-weight: 600;
  transition: color .15s;
}
.flags-inline input:checked + span { color: #5f7dff; }

.pattern-error {
  font-size: 11px;
  color: #ff6060;
  margin-top: 6px;
  min-height: 16px;
  font-family: monospace;
}

/* ---- Textarea ---- */
textarea {
  width: 100%;
  background: #111420;
  border: 1px solid #1e2340;
  border-radius: 8px;
  color: #e0e0e0;
  font-size: 12px;
  font-family: 'Menlo', 'Monaco', 'Courier New', monospace;
  padding: 10px;
  resize: vertical;
  height: 160px;
  outline: none;
  transition: border-color .15s;
  line-height: 1.6;
}
textarea:focus { border-color: #3a4070; }

/* ---- Cheatsheet ---- */
.cheatsheet {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.cheat-row {
  display: flex;
  align-items: baseline;
  gap: 10px;
}
.cheat-row code {
  font-family: 'Menlo', 'Monaco', 'Courier New', monospace;
  font-size: 11px;
  color: #8ea0ff;
  background: rgba(95,125,255,0.08);
  padding: 1px 5px;
  border-radius: 4px;
  min-width: 58px;
  display: inline-block;
}
.cheat-row span {
  font-size: 11px;
  color: #555;
}

/* ---- Divider ---- */
hr { border: none; border-top: 1px solid #1c1c1c; }

/* ---- Output side ---- */
.output-side {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

.output-topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 20px;
  border-bottom: 1px solid rgba(70, 80, 150, 0.18);
  background: rgba(10, 13, 28, 0.8);
  flex-shrink: 0;
}

.status-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 20px;
  letter-spacing: 0.05em;
}
.status-badge.idle    { background: rgba(100,100,120,0.2); color: #555; border: 1px solid #222; }
.status-badge.match   { background: rgba(0, 200, 120, 0.12); color: #00c878; border: 1px solid rgba(0,200,120,0.25); }
.status-badge.no-match { background: rgba(255,160,0,0.1); color: #ffa040; border: 1px solid rgba(255,160,0,0.25); }
.status-badge.invalid { background: rgba(255, 80, 80, 0.12); color: #ff6060; border: 1px solid rgba(255,80,80,0.25); }

.output-meta {
  flex: 1;
  font-size: 11px;
  color: #444;
  font-family: monospace;
}

/* ---- Output panels ---- */
.output-panels {
  flex: 1;
  display: grid;
  grid-template-rows: 1fr 1fr;
  overflow: hidden;
}

.output-section {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-bottom: 1px solid rgba(70,80,150,0.12);
}
.output-section:last-child { border-bottom: none; }

.output-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: #333;
  padding: 10px 20px 6px;
  flex-shrink: 0;
}

/* ---- Highlighted text ---- */
.highlighted-wrap {
  flex: 1;
  overflow: auto;
  padding: 0 20px 16px;
  scrollbar-width: thin;
  scrollbar-color: #1e1e1e transparent;
}
.highlighted-wrap::-webkit-scrollbar { width: 6px; }
.highlighted-wrap::-webkit-scrollbar-track { background: transparent; }
.highlighted-wrap::-webkit-scrollbar-thumb { background: #1e1e1e; border-radius: 4px; }

.highlighted-text {
  font-family: 'Menlo', 'Monaco', 'Courier New', monospace;
  font-size: 13px;
  line-height: 1.8;
  white-space: pre-wrap;
  word-break: break-all;
}

mark {
  background: rgba(255, 210, 0, 0.28);
  color: #ffd200;
  border-radius: 2px;
  padding: 0 1px;
  outline: 1px solid rgba(255,210,0,0.35);
}

.placeholder { color: #333; font-style: italic; font-family: inherit; }

/* ---- Match list ---- */
.match-list {
  flex: 1;
  overflow-y: auto;
  padding: 0 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  scrollbar-width: thin;
  scrollbar-color: #1e1e1e transparent;
}
.match-list::-webkit-scrollbar { width: 6px; }
.match-list::-webkit-scrollbar-track { background: transparent; }
.match-list::-webkit-scrollbar-thumb { background: #1e1e1e; border-radius: 4px; }

.match-item {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 6px 10px;
  background: rgba(255,210,0,0.04);
  border: 1px solid rgba(255,210,0,0.1);
  border-radius: 6px;
  font-family: monospace;
  font-size: 12px;
}

.match-index {
  font-size: 10px;
  color: #555;
  min-width: 20px;
  flex-shrink: 0;
}

.match-value {
  color: #ffd200;
  flex: 1;
  word-break: break-all;
}

.match-pos {
  font-size: 10px;
  color: #444;
  flex-shrink: 0;
}

.match-groups {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
}

.match-group-tag {
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 4px;
  background: rgba(95,125,255,0.1);
  color: #8ea0ff;
  border: 1px solid rgba(95,125,255,0.2);
}

/* ---- Mobile ---- */
@media (max-width: 700px) {
  html, body { overflow: auto; height: auto; }

  .container {
    grid-template-columns: 1fr;
    height: auto;
    min-height: 100vh;
  }

  .panel { height: auto; overflow: visible; border-right: none; border-bottom: 1px solid rgba(70,80,150,0.18); }
  .panel-body { overflow: visible; }

  .output-side { height: auto; }
  .output-panels { grid-template-rows: auto auto; }
  .highlighted-wrap, .match-list { max-height: 260px; }
}
