:root {
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
  --green: #15803d;
  --green-dark: #166534;
  --green-soft: #ecfdf3;
  --ink: #17211b;
  --muted: #66736b;
  --line: #dce3de;
  --surface: #ffffff;
  --canvas: #f5f7f5;
  --danger: #b42318;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  min-height: 100%;
  margin: 0;
  color: var(--ink);
  background: var(--canvas);
}

button,
input,
textarea {
  font: inherit;
  letter-spacing: 0;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

[hidden] {
  display: none !important;
}

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-panel {
  width: min(100%, 390px);
  padding: 28px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 12px 32px rgba(23, 33, 27, 0.08);
}

.brand,
.topbar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  font-weight: 700;
  text-decoration: none;
}

.brand img,
.topbar-brand img {
  width: 30px;
  height: 30px;
}

.login-panel h1 {
  margin: 30px 0 8px;
  font-size: 24px;
  line-height: 1.25;
}

.muted,
.field-hint {
  color: var(--muted);
}

.muted {
  margin: 0 0 24px;
  font-size: 14px;
}

label {
  display: block;
  margin: 16px 0 7px;
  font-size: 13px;
  font-weight: 650;
}

input {
  width: 100%;
  height: 40px;
  padding: 0 11px;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid #b9c5bd;
  border-radius: 6px;
  outline: none;
}

input:focus,
textarea:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(21, 128, 61, 0.12);
}

.field-hint {
  margin: 8px 0 0;
  font-size: 12px;
}

.error {
  margin: 16px 0 0;
  color: var(--danger);
  font-size: 13px;
}

.button {
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 14px;
  border: 1px solid transparent;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 650;
  text-decoration: none;
  white-space: nowrap;
}

.button:disabled {
  cursor: wait;
  opacity: 0.6;
}

.button.primary {
  color: #fff;
  background: var(--green);
  border-color: var(--green);
}

.button.primary:hover:not(:disabled) {
  background: var(--green-dark);
  border-color: var(--green-dark);
}

.button.quiet {
  color: #36463c;
  background: var(--surface);
  border-color: var(--line);
}

.button.quiet:hover:not(:disabled) {
  background: #eef2ef;
}

.button.full {
  width: 100%;
  margin-top: 22px;
}

.back-link {
  display: block;
  margin-top: 20px;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
  text-underline-offset: 3px;
}

.editor-shell {
  height: 100vh;
  min-height: 620px;
  display: grid;
  grid-template-rows: 58px minmax(0, 1fr);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 0 18px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.topbar-actions,
.document-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.identity {
  max-width: 240px;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.workspace {
  min-height: 0;
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
}

.sidebar {
  min-width: 0;
  overflow: hidden;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  background: #f8faf8;
  border-right: 1px solid var(--line);
}

.sidebar-header {
  padding: 16px 14px 12px;
  border-bottom: 1px solid var(--line);
}

.sidebar-header label {
  margin: 0 0 8px;
}

.file-list {
  overflow-y: auto;
  padding: 8px;
}

.file-item {
  width: 100%;
  min-width: 0;
  display: block;
  padding: 9px 10px;
  color: #34443a;
  background: transparent;
  border: 0;
  border-radius: 5px;
  cursor: pointer;
  text-align: left;
}

.file-item:hover {
  background: #edf2ee;
}

.file-item.active {
  color: var(--green-dark);
  background: #dcf5e5;
}

.file-title,
.file-path {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-title {
  font-size: 13px;
  font-weight: 650;
}

.file-path {
  margin-top: 3px;
  color: #718078;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11px;
}

.editor-main {
  min-width: 0;
  min-height: 0;
  background: var(--surface);
}

.empty-state {
  height: 100%;
  display: grid;
  align-content: center;
  justify-items: center;
  color: var(--muted);
}

.empty-state h1 {
  margin: 0 0 8px;
  color: #3f4d44;
  font-size: 20px;
}

.empty-state p {
  margin: 0;
  font-size: 14px;
}

.document-editor {
  height: 100%;
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) 34px;
}

.document-toolbar {
  min-height: 74px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--line);
}

.document-meta {
  min-width: 0;
}

.document-meta h1 {
  overflow: hidden;
  margin: 0 0 5px;
  font-size: 17px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.document-meta code {
  display: block;
  overflow: hidden;
  color: var(--muted);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dirty-indicator {
  color: #9a6700;
  font-size: 12px;
}

#markdown-editor {
  width: 100%;
  height: 100%;
  min-height: 0;
  resize: none;
  padding: 22px;
  color: #1e2922;
  background: #fbfcfb;
  border: 0;
  border-radius: 0;
  outline: none;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  font-size: 14px;
  line-height: 1.65;
  tab-size: 2;
}

#markdown-editor:focus {
  box-shadow: inset 3px 0 var(--green);
}

.statusbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 18px;
  color: var(--muted);
  background: #f7f9f7;
  border-top: 1px solid var(--line);
  font-size: 11px;
}

@media (max-width: 760px) {
  .editor-shell {
    height: auto;
    min-height: 100vh;
    grid-template-rows: auto auto;
  }

  .topbar {
    min-height: 58px;
    flex-wrap: wrap;
    padding: 10px 12px;
  }

  .identity {
    display: none;
  }

  .workspace {
    grid-template-columns: 1fr;
    grid-template-rows: 220px minmax(600px, calc(100vh - 278px));
  }

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .document-toolbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .document-actions {
    width: 100%;
    flex-wrap: wrap;
  }

  .dirty-indicator {
    flex: 1 1 100%;
  }

  #markdown-editor {
    padding: 16px;
    font-size: 13px;
  }
}
