:root {
  --bg: #010604;
  --panel: rgba(2, 13, 9, 0.54);
  --green: #35e56c;
  --green-dim: #198b47;
  --green-faint: rgba(53, 229, 108, 0.16);
  --text: #30d965;
  --muted: #22a854;
  --danger: #ff6b6b;
  --border: rgba(53, 229, 108, 0.72);
  --font: "Cascadia Mono", "Lucida Console", "Courier New", monospace;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: #000;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  color: var(--text);
  background:
    radial-gradient(circle at 50% 0%, rgba(31, 90, 52, 0.10), transparent 45%),
    #000;
  font-family: var(--font);
  font-size: clamp(13px, 0.92vw, 18px);
  letter-spacing: 0.015em;
  text-shadow: 0 0 7px rgba(53, 229, 108, 0.28);
}

button,
input,
textarea {
  font: inherit;
}

button {
  color: inherit;
}

.crt-shell {
  position: relative;
  width: min(100%, 1920px);
  min-height: 100vh;
  margin: 0 auto;
  padding: clamp(22px, 3vw, 52px);
  overflow: hidden;
  isolation: isolate;
  background:
    linear-gradient(rgba(3, 14, 10, 0.72), rgba(1, 6, 4, 0.83)),
    repeating-linear-gradient(
      90deg,
      rgba(255, 255, 255, 0.012) 0,
      rgba(255, 255, 255, 0.012) 1px,
      transparent 1px,
      transparent 4px
    );
}

.crt-shell::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 20;
  box-shadow:
    inset 0 0 90px rgba(0, 0, 0, 0.82),
    inset 0 0 12px rgba(51, 239, 112, 0.08);
}

.scanlines {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 18;
  opacity: 0.34;
  background: repeating-linear-gradient(
    0deg,
    rgba(0, 0, 0, 0.22) 0,
    rgba(0, 0, 0, 0.22) 1px,
    transparent 1px,
    transparent 4px
  );
}

.screen-glow {
  position: fixed;
  inset: -10%;
  pointer-events: none;
  z-index: -1;
  filter: blur(50px);
  background: radial-gradient(circle, rgba(32, 139, 72, 0.06), transparent 62%);
}

.site-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 30px;
  min-height: 110px;
  padding: 0 4px 18px;
  border-bottom: 1px solid var(--border);
}

.system-identity {
  line-height: 1.45;
}

.version {
  margin-bottom: 12px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 18px;
  color: var(--green);
  font-size: clamp(20px, 2vw, 36px);
  font-weight: 700;
  text-decoration: none;
  letter-spacing: 0.02em;
}

.eye-logo {
  width: clamp(58px, 5.2vw, 88px);
  height: auto;
  overflow: visible;
  fill: none;
  stroke: currentColor;
  stroke-linecap: square;
  stroke-linejoin: miter;
  shape-rendering: crispEdges;
  filter: drop-shadow(0 0 8px rgba(53, 229, 108, 0.32));
}

.eye-outline {
  fill: rgba(53, 229, 108, 0.025);
  stroke-width: 3;
}

.eye-iris {
  stroke-width: 3;
}

.eye-pupil {
  fill: currentColor;
  stroke: none;
}

.eye-veins {
  stroke-width: 2;
}

.tabs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin: 18px 0 24px;
}

.tab,
.terminal-button,
.footer-commands button {
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.18);
  color: var(--green);
  cursor: pointer;
  transition:
    background 120ms ease,
    color 120ms ease,
    box-shadow 120ms ease;
}

.tab {
  min-height: 48px;
  padding: 10px 14px;
  font-weight: 700;
  font-size: 1.05em;
}

.tab:hover,
.tab:focus-visible,
.terminal-button:hover,
.terminal-button:focus-visible {
  background: var(--green-faint);
  outline: none;
  box-shadow: 0 0 14px rgba(53, 229, 108, 0.12);
}

.tab.is-active {
  color: #021006;
  background:
    repeating-linear-gradient(
      0deg,
      rgba(41, 207, 94, 0.92) 0,
      rgba(41, 207, 94, 0.92) 2px,
      rgba(51, 231, 107, 0.82) 2px,
      rgba(51, 231, 107, 0.82) 4px
    );
  box-shadow:
    inset 0 0 0 3px rgba(0, 15, 7, 0.38),
    0 0 14px rgba(53, 229, 108, 0.16);
}

.page {
  display: none;
}

.page.is-active {
  display: block;
  animation: page-in 160ms ease-out;
}

@keyframes page-in {
  from { opacity: 0.4; transform: translateY(2px); }
  to { opacity: 1; transform: translateY(0); }
}

.section-heading {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0 4px 16px;
  font-weight: 700;
  font-size: 1.02em;
}

.section-heading::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

.dashboard-grid {
  display: grid;
  grid-template-columns: 1.1fr 1fr 0.86fr 1.18fr;
  gap: 18px;
}

.panel {
  position: relative;
  min-width: 0;
  border: 1px solid var(--border);
  background:
    linear-gradient(rgba(4, 19, 12, 0.38), rgba(0, 0, 0, 0.25));
}

.panel > h2,
.chat-rules h2 {
  margin: 0;
  padding: 11px 14px;
  border-bottom: 1px solid rgba(53, 229, 108, 0.48);
  font-size: 1em;
  font-weight: 700;
}

.terminal-list {
  margin: 0;
  padding: 18px 14px;
}

.terminal-list > div {
  display: grid;
  grid-template-columns: minmax(120px, 1fr) minmax(100px, 1.05fr);
  gap: 12px;
  line-height: 1.34;
}

.terminal-list dt,
.terminal-list dd {
  margin: 0;
}

.terminal-list dd {
  overflow-wrap: anywhere;
}

.panel-note {
  margin: 0;
  padding: 16px 14px 18px;
  line-height: 1.4;
}

.table-scroll {
  overflow-x: auto;
  scrollbar-color: var(--green-dim) transparent;
}

.terminal-table {
  width: 100%;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
}

.terminal-table th,
.terminal-table td {
  padding: 5px 12px;
  text-align: left;
  white-space: nowrap;
}

.terminal-table th {
  border-bottom: 1px dashed var(--border);
  font-weight: 400;
}

.meter-wrap {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 8px 14px 18px;
}

.meter {
  height: 13px;
  border: 1px solid var(--border);
  padding: 2px;
}

.meter > div {
  height: 100%;
  background: repeating-linear-gradient(
    90deg,
    var(--green) 0,
    var(--green) 3px,
    transparent 3px,
    transparent 5px
  );
}

.panel-wide {
  grid-column: span 2;
  min-height: 306px;
}

.log-output {
  padding: 14px;
  line-height: 1.38;
  min-height: 232px;
  font-variant-numeric: tabular-nums;
}

.log-line {
  white-space: pre-wrap;
}

.prompt-line {
  padding: 0 14px 14px;
}

.block-cursor {
  display: inline-block;
  width: 0.72em;
  height: 1.05em;
  margin-left: 4px;
  vertical-align: -0.12em;
  background: var(--green);
  box-shadow: 0 0 8px rgba(53, 229, 108, 0.6);
  animation: cursor-blink 0.95s steps(1, end) infinite;
}

@keyframes cursor-blink {
  50% { opacity: 0; }
}

.status-banner {
  margin: 16px 14px 14px;
  padding: 10px 14px;
  border: 1px solid var(--border);
}

.system-notes {
  padding: 12px 14px;
  line-height: 1.35;
}

.system-note + .system-note {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px dashed rgba(53, 229, 108, 0.45);
}

.notes-layout {
  display: grid;
  grid-template-columns: minmax(310px, 0.8fr) minmax(0, 1.75fr);
  gap: 18px;
  min-height: 600px;
}

.panel-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  min-height: 48px;
  padding: 8px 14px;
  border-bottom: 1px solid rgba(53, 229, 108, 0.56);
  font-weight: 700;
}

.sort-control,
.select-shell {
  display: inline-flex;
  align-items: center;
}

.sort-control {
  gap: 8px;
}

.select-shell {
  position: relative;
}

.sort-control select {
  min-width: 112px;
  padding: 5px 26px 5px 7px;
  border: 0;
  border-bottom: 1px solid transparent;
  border-radius: 0;
  appearance: none;
  color: var(--green);
  background: #010604;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  outline: none;
}

.sort-control select:hover,
.sort-control select:focus-visible {
  border-bottom-color: var(--green);
  background: var(--green-faint);
}

.sort-control option {
  color: var(--green);
  background: #010604;
}

.select-arrow {
  position: absolute;
  right: 7px;
  pointer-events: none;
}

.notes-index {
  display: flex;
  flex-direction: column;
}

.notes-list {
  flex: 1;
  padding: 10px 6px;
}

.note-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 38px;
  align-items: stretch;
  min-height: 38px;
}

.note-row:not(:has(.delete-icon-button)) {
  grid-template-columns: 1fr;
}

.note-list-button {
  display: grid;
  grid-template-columns: 116px minmax(0, 1fr);
  width: 100%;
  padding: 8px 12px;
  border: 0;
  background: transparent;
  color: var(--text);
  text-align: left;
  cursor: pointer;
  overflow: hidden;
}

.note-list-button span:last-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.note-row:hover,
.note-row:focus-within,
.note-row.is-selected {
  color: #031107;
  background: var(--green);
  text-shadow: none;
}

.note-row:hover .note-list-button,
.note-row:focus-within .note-list-button,
.note-row.is-selected .note-list-button,
.note-row:hover .icon-button,
.note-row:focus-within .icon-button,
.note-row.is-selected .icon-button {
  color: #031107;
}

.note-list-button:focus-visible {
  outline: 1px solid #031107;
  outline-offset: -3px;
}

.notes-index > .terminal-button {
  margin: 8px 12px 12px;
}

.note-reader {
  display: flex;
  flex-direction: column;
}

#note-view {
  display: flex;
  flex: 1;
  flex-direction: column;
  padding: 20px 24px 16px;
}

#note-title {
  margin: 0 0 8px;
  color: var(--green);
  font-size: clamp(24px, 2.4vw, 42px);
  line-height: 1.2;
}

.note-meta {
  padding-bottom: 14px;
  border-bottom: 1px dashed var(--border);
  line-height: 1.6;
}

.divider {
  margin: 0 10px;
}

.note-body {
  flex: 1;
  min-height: 330px;
  padding: 20px 0;
  white-space: pre-wrap;
  line-height: 1.48;
}

.note-footer {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

.reader-actions {
  padding: 0 24px 20px;
}

.note-editor {
  display: grid;
  gap: 14px;
  padding: 22px;
}

.note-editor label {
  display: grid;
  gap: 7px;
}

.note-editor input,
.note-editor textarea,
.chat-input-wrap input,
.terminal-dialog input {
  border: 1px solid var(--border);
  border-radius: 0;
  background: #010604;
  color: var(--green);
  outline: none;
  caret-color: var(--green);
  box-shadow: inset 0 0 12px rgba(53, 229, 108, 0.035);
}

.note-editor input,
.terminal-dialog input {
  min-height: 42px;
  padding: 8px 10px;
}

.note-editor textarea {
  min-height: 310px;
  padding: 12px;
  resize: vertical;
  line-height: 1.45;
}

.note-editor input:focus,
.note-editor textarea:focus,
.chat-input-wrap input:focus,
.terminal-dialog input:focus {
  box-shadow: inset 0 0 0 1px var(--green), 0 0 12px rgba(53, 229, 108, 0.08);
}

.editor-actions,
.dialog-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.terminal-button {
  min-height: 40px;
  padding: 8px 14px;
}

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 36px;
  min-width: 36px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--green);
  cursor: pointer;
}

.icon-button svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
  shape-rendering: crispEdges;
}

.icon-button:hover,
.icon-button:focus-visible {
  color: var(--danger);
  outline: 1px solid currentColor;
  outline-offset: -4px;
}

.terminal-button.danger {
  color: var(--danger);
  border-color: rgba(255, 107, 107, 0.7);
}

.chat-layout {
  display: grid;
  grid-template-columns: minmax(0, 3.3fr) minmax(260px, 1fr);
  gap: 18px;
  min-height: 610px;
}

.chat-main {
  display: grid;
  grid-template-rows: 1fr auto;
  gap: 14px;
  min-width: 0;
}

.chat-feed {
  height: 540px;
  overflow-y: auto;
  padding: 8px 20px 18px;
  scrollbar-color: var(--green-dim) transparent;
}

.chat-message {
  padding: 13px 0;
  border-bottom: 1px dashed rgba(53, 229, 108, 0.32);
}

.chat-message:last-child {
  border-bottom: 0;
}

.chat-message-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 16px;
  min-height: 28px;
  margin-bottom: 5px;
}

.chat-delete-button {
  margin-left: auto;
}

.chat-author {
  font-weight: 700;
}

.chat-message-body {
  white-space: pre-wrap;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.chat-input-wrap {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 8px;
  min-height: 50px;
  padding: 0 14px;
  border: 1px solid var(--border);
  background: var(--panel);
}

.chat-input-wrap input {
  width: 100%;
  height: 46px;
  padding: 0 4px;
  border: 0;
  caret-color: var(--green);
  box-shadow: none;
}

.input-focus-cursor {
  width: 2px;
  height: 1.25em;
  opacity: 0;
  background: var(--green);
  box-shadow: 0 0 8px rgba(53, 229, 108, 0.6);
}

.chat-input-wrap:focus-within {
  box-shadow:
    inset 0 0 0 1px var(--green),
    0 0 14px rgba(53, 229, 108, 0.10);
}

.chat-input-wrap:focus-within .input-focus-cursor {
  opacity: 1;
  animation: cursor-blink 0.95s steps(1, end) infinite;
}

.chat-input-wrap input::placeholder {
  color: var(--muted);
  opacity: 1;
}

.chat-sidebar {
  align-self: stretch;
}

.chat-rules {
  border-top: 1px solid var(--border);
}

.chat-rules p {
  margin: 0;
  padding: 8px 14px 0;
}

.media-placeholder {
  display: grid;
  place-items: center;
  min-height: 600px;
  text-align: center;
  font-size: 1.15em;
}

.site-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 22px;
  margin-top: 20px;
  padding: 14px 8px 0;
  border-top: 1px solid var(--border);
}

.footer-commands {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
}

.footer-commands button {
  padding: 0;
  border: 0;
  background: transparent;
}

.footer-commands button:hover,
.footer-commands button:focus-visible {
  color: #92f9ad;
  outline: none;
}

.footer-clock {
  display: flex;
  gap: 34px;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.toast {
  position: fixed;
  right: 28px;
  bottom: 28px;
  z-index: 50;
  max-width: min(420px, calc(100vw - 56px));
  padding: 12px 16px;
  border: 1px solid var(--border);
  background: #010604;
  color: var(--green);
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition: opacity 150ms ease, transform 150ms ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.terminal-dialog {
  width: min(520px, calc(100vw - 32px));
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 0;
  color: var(--green);
  background: #010604;
  box-shadow: 0 0 40px rgba(0, 0, 0, 0.75);
}

.terminal-dialog::backdrop {
  background: rgba(0, 0, 0, 0.76);
  backdrop-filter: blur(2px);
}

.terminal-dialog form {
  padding: 22px;
}

.terminal-dialog h2 {
  margin-top: 0;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

.terminal-dialog input {
  width: 100%;
  margin: 4px 0 16px;
}

[hidden] {
  display: none !important;
}

@media (max-width: 1250px) {
  .dashboard-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .panel-wide {
    grid-column: span 1;
  }

  .notes-layout {
    grid-template-columns: minmax(280px, 0.72fr) minmax(0, 1.45fr);
  }
}

@media (max-width: 860px) {
  .crt-shell {
    padding: 20px 14px 28px;
  }

  .site-header {
    min-height: auto;
  }

  .brand {
    font-size: 18px;
  }

  .eye-logo {
    width: 52px;
  }

  .tabs {
    grid-template-columns: repeat(2, 1fr);
  }

  .dashboard-grid,
  .notes-layout,
  .chat-layout {
    grid-template-columns: 1fr;
  }

  .notes-layout,
  .chat-layout {
    min-height: auto;
  }

  .chat-feed {
    height: 480px;
  }

  .site-footer {
    align-items: flex-start;
    flex-direction: column;
  }

  .footer-clock {
    width: 100%;
    justify-content: space-between;
  }
}

@media (max-width: 560px) {
  body {
    font-size: 12px;
  }

  .site-header {
    flex-direction: column-reverse;
    gap: 14px;
  }

  .brand {
    align-self: flex-end;
  }

  .tabs {
    gap: 8px;
  }

  .tab {
    min-height: 42px;
    padding: 8px;
  }

  .terminal-list > div {
    grid-template-columns: 1fr 1fr;
  }

  .panel-toolbar,
  .note-footer {
    align-items: flex-start;
    flex-direction: column;
  }

  #note-view {
    padding: 18px 14px;
  }

  .note-list-button {
    grid-template-columns: 96px 1fr;
  }

  .footer-commands {
    gap: 12px;
  }
}

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