/* Algo Pad - dark theme, monospace, plain-text editing */
:root {
  --bg: #0d1117;
  --bg-panel: #161b22;
  --bg-hover: #1f2630;
  --bg-active: #22304a;
  --border: #30363d;
  --text: #c9d1d9;
  --text-dim: #8b949e;
  --accent: #58a6ff;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas,
    "Liberation Mono", monospace;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--mono);
  font-size: 14px;
}

.app {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

.panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.panel-left {
  flex: 0 0 clamp(320px, 32vw, 460px);
  border-right: 1px solid var(--border);
  background: var(--bg-panel);
}

.panel-right {
  flex: 1;
  min-width: 0;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  flex: 0 0 auto;
}

.panel-header h1,
.panel-header h2 {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--text);
}

.panel-header h2 {
  color: var(--text-dim);
  font-weight: 500;
}

/* ---------- Problem statement ---------- */
.problem-detail {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 12px 16px;
  gap: 10px;
  overflow: hidden;
}

.problem-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.problem-title {
  font-size: 15px;
  font-weight: 600;
}

.problem-description {
  flex: 1;
  min-height: 0;
  margin: 0;
  padding: 12px 14px;
  overflow-y: auto;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-family: inherit;
  font-size: 13px;
  line-height: 1.7;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--text);
}

/* ---------- Buttons ---------- */
.btn {
  padding: 4px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-panel);
  color: var(--text);
  font-family: inherit;
  font-size: 12px;
  cursor: pointer;
}

.btn:hover {
  background: var(--bg-hover);
  border-color: var(--text-dim);
}

.btn-ghost {
  padding: 2px 10px;
  font-size: 11px;
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
}

.save-hint {
  font-size: 12px;
  color: var(--text-dim);
}

/* ---------- Editor ---------- */
.editor {
  flex: 1;
  min-height: 0;
  width: 100%;
  padding: 14px 16px;
  border: none;
  resize: none;
  outline: none;
  background: var(--bg);
  color: var(--text);
  font-family: var(--mono);
  font-size: 14px;
  line-height: 1.6;
  tab-size: 4;
  white-space: pre;
  overflow: auto;
}

.editor::placeholder {
  color: var(--text-dim);
  opacity: 0.6;
}

.status-bar {
  display: flex;
  gap: 16px;
  align-items: center;
  padding: 6px 16px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-dim);
  flex: 0 0 auto;
}

.status-bar .spacer {
  flex: 1;
}

/* ---------- Scrollbars ---------- */
::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-thumb {
  background: #30363d;
  border-radius: 5px;
}

::-webkit-scrollbar-thumb:hover {
  background: #484f58;
}

::-webkit-scrollbar-track {
  background: transparent;
}

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--bg-active);
  border: 1px solid var(--accent);
  color: var(--text);
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 10;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ---------- Narrow screens: stack vertically ---------- */
@media (max-width: 860px) {
  .app {
    flex-direction: column;
    overflow: auto;
    height: auto;
    min-height: 100vh;
  }

  .panel-left {
    flex: none;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  .problem-detail {
    max-height: 50vh;
  }

  .panel-right {
    min-height: 60vh;
  }
}
