:root {
  color-scheme: dark;
  --app: #1e1e1e;
  --panel: #252526;
  --control: #2d2d30;
  --hover: #3e3e42;
  --accent: #4fc1ff;
  --accent-soft: rgba(79, 193, 255, 0.15);
  --text: #d4d4d4;
  --muted: #9da3a6;
  --border: #3f3f46;
  --selection: #264f78;
  --warn: #f6c177;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  overflow: hidden;
  background: #111;
  color: var(--text);
  font-family: "Segoe UI", Arial, sans-serif;
}
button, input { font: inherit; }
button { color: inherit; }

.textopener-shell {
  width: 100vw;
  height: 100vh;
  min-width: 980px;
  display: grid;
  grid-template-rows: 34px minmax(0, 1fr) 30px;
  position: relative;
  background: var(--app);
  border: 1px solid #171717;
}

.menu-bar {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 0 8px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  user-select: none;
}
.menu-bar button {
  height: 28px;
  border: 0;
  background: transparent;
  padding: 0 12px;
  color: var(--text);
  cursor: pointer;
}
.menu-bar button:hover { background: var(--hover); }
.window-title {
  margin-left: auto;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: .02em;
}

.workspace {
  min-height: 0;
  display: grid;
  grid-template-columns: 250px minmax(0, 1fr);
}
.sidebar {
  min-height: 0;
  overflow: hidden;
  background: var(--panel);
  border-right: 1px solid var(--border);
  display: grid;
  grid-template-rows: minmax(120px, 1fr) minmax(120px, 1fr) minmax(100px, 1fr);
}
.sidebar-section {
  min-height: 0;
  overflow: auto;
  border-bottom: 1px solid rgba(63, 63, 70, .65);
  padding-bottom: 8px;
}
.sidebar-section h2 {
  margin: 12px 10px 5px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1;
  text-transform: uppercase;
  letter-spacing: .12em;
}
.file-row {
  width: calc(100% - 12px);
  min-height: 32px;
  margin: 0 6px 2px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  padding: 5px 8px;
  color: var(--text);
  text-align: left;
  cursor: pointer;
}
.file-row span {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.file-row:hover { background: var(--hover); }
.file-row.active { background: var(--selection); }
.file-row strong { color: var(--accent); }

.editor-area {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: 36px minmax(0, 1fr) auto;
}
.tab-strip {
  display: flex;
  overflow-x: auto;
  background: #1a1a1a;
  border-bottom: 1px solid var(--border);
}
.tab {
  min-width: 150px;
  max-width: 220px;
  height: 36px;
  border: 0;
  border-right: 1px solid var(--border);
  background: var(--control);
  color: var(--text);
  padding: 0 12px;
  text-align: left;
  cursor: pointer;
}
.tab.active { background: var(--app); color: #fff; box-shadow: inset 0 2px 0 var(--accent); }
.tab .dirty { color: var(--accent); margin-left: 6px; }

.editor-panel {
  min-height: 0;
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr);
  overflow: hidden;
  background: var(--app);
}
.line-numbers {
  padding: 14px 10px 14px 0;
  background: #1b1b1b;
  border-right: 1px solid rgba(63, 63, 70, .38);
  color: #666b70;
  text-align: right;
  line-height: 1.55;
  font: 14px Consolas, "Cascadia Mono", monospace;
  user-select: none;
}
.editor-text {
  margin: 0;
  min-height: 0;
  overflow: auto;
  white-space: pre-wrap;
  word-break: normal;
  padding: 14px;
  color: var(--text);
  line-height: 1.55;
  font: 15px Consolas, "Cascadia Mono", monospace;
  outline: none;
}
.editor-text mark {
  background: rgba(79, 193, 255, .28);
  color: #ffffff;
  border-radius: 2px;
}

.find-panel {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px;
  background: var(--control);
  border-top: 1px solid var(--border);
}
.find-panel[hidden] { display: none; }
.find-panel label { color: var(--muted); }
.find-panel input {
  min-width: 220px;
  height: 30px;
  background: #1e1e1e;
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0 9px;
}
.find-panel button,
.command-palette button {
  min-height: 30px;
  border: 1px solid var(--border);
  background: var(--control);
  color: var(--text);
  padding: 0 11px;
  cursor: pointer;
}
.find-panel button:hover,
.command-palette button:hover { border-color: var(--accent); background: var(--hover); }

.statusbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 18px;
  padding: 0 10px;
  background: var(--panel);
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 12px;
}
.statusbar span:first-child { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }

.command-palette {
  position: absolute;
  right: 18px;
  bottom: 46px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(37, 37, 38, .96);
  box-shadow: 0 18px 50px rgba(0, 0, 0, .3);
}
.command-palette button:first-child { border-color: var(--accent); background: var(--accent-soft); }

.flash {
  animation: flashStatus .3s ease;
}
@keyframes flashStatus {
  from { color: #ffffff; }
  to { color: var(--muted); }
}

@media (max-width: 980px) {
  body { overflow: auto; }
  .textopener-shell {
    min-width: 0;
    height: auto;
    min-height: 100vh;
    grid-template-rows: auto auto 30px;
  }
  .menu-bar { min-height: 36px; }
  .workspace { grid-template-columns: 1fr; }
  .sidebar {
    max-height: 230px;
    grid-template-columns: repeat(3, minmax(180px, 1fr));
    grid-template-rows: 1fr;
    overflow-x: auto;
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }
  .sidebar-section { border-bottom: 0; border-right: 1px solid rgba(63, 63, 70, .65); }
  .editor-area { min-height: 650px; }
  .command-palette { position: static; margin: 10px; }
}

@media (max-width: 560px) {
  .window-title { display: none; }
  .sidebar { grid-template-columns: 1fr; max-height: 260px; }
  .recent { display: none; }
  .editor-panel { grid-template-columns: 42px minmax(0, 1fr); }
  .line-numbers { font-size: 12px; }
  .editor-text { font-size: 13px; }
  .find-panel { align-items: stretch; flex-wrap: wrap; }
  .find-panel input { min-width: 0; flex: 1 1 160px; }
  .command-palette button { flex: 1 1 120px; }
}