:root {
  color-scheme: light;
  --bg: #f7f8fb;
  --panel: #ffffff;
  --line: #d9dee8;
  --text: #1f2937;
  --muted: #697386;
  --accent: #0f766e;
  --accent-soft: #d9f4ee;
  --danger: #b42318;
  --focus: #2563eb;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
textarea {
  font: inherit;
}

button {
  border: 0;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  min-height: 40px;
  padding: 0 14px;
}

button:hover {
  filter: brightness(0.95);
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  padding: 10px 12px;
  outline: none;
}

input[type="file"] {
  border-style: dashed;
  color: var(--muted);
}

textarea {
  min-height: 112px;
  resize: vertical;
  line-height: 1.5;
}

input:focus,
textarea:focus {
  border-color: var(--focus);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

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

.topbar div {
  display: flex;
  gap: 10px;
  align-items: baseline;
}

.top-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.nav-button {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  border-radius: 6px;
  background: #e8eef7;
  color: var(--text);
  padding: 0 12px;
  text-decoration: none;
}

.topbar span,
time {
  color: var(--muted);
  font-size: 13px;
}

.icon-button,
.danger-button {
  width: 40px;
  padding: 0;
}

.workspace {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  min-height: calc(100vh - 56px);
}

.sidebar {
  border-right: 1px solid var(--line);
  background: #eef2f6;
  padding: 14px;
}

.new-category,
.content-head,
.rename-form,
.item-actions,
.card-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.new-category button,
.rename-form button {
  width: 40px;
  padding: 0;
  flex: 0 0 40px;
}

.category-list {
  display: grid;
  gap: 6px;
  margin-top: 14px;
}

.category-list a {
  display: flex;
  align-items: center;
  min-height: 40px;
  border-radius: 6px;
  color: var(--text);
  padding: 0 12px;
  text-decoration: none;
}

.category-list a:hover,
.category-list a.active {
  background: var(--accent-soft);
  color: #064e3b;
}

.content {
  padding: 18px;
  max-width: 1080px;
  width: 100%;
}

.content-head {
  justify-content: space-between;
  margin-bottom: 14px;
}

.rename-form {
  max-width: 420px;
  width: 100%;
}

.danger-button,
.danger-link {
  background: var(--danger);
}

.message-editor {
  display: grid;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 14px;
}

.message-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, 300px);
  gap: 12px;
  margin-top: 14px;
}

.message-item {
  display: grid;
  gap: 8px;
  width: 300px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 14px;
}

.message-readonly {
  display: grid;
  gap: 8px;
}

.message-readonly h2 {
  overflow-wrap: anywhere;
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  line-height: 1.35;
}

.message-readonly p {
  min-height: 72px;
  overflow-wrap: anywhere;
  margin: 0;
  color: var(--text);
  line-height: 1.5;
  white-space: pre-wrap;
}

.item-actions {
  justify-content: space-between;
}

.card-actions {
  justify-content: space-between;
}

.danger-link {
  min-height: 34px;
  padding: 0 12px;
}

.file-link {
  display: inline-flex;
  width: fit-content;
  color: var(--focus);
  font-size: 14px;
  text-decoration: none;
}

.file-link:hover {
  text-decoration: underline;
}

.file-input {
  display: grid;
  gap: 6px;
  border: 1px dashed var(--accent);
  border-radius: 8px;
  background: #f0fdfa;
  color: var(--muted);
  font-size: 13px;
  padding: 10px;
}

.file-input strong {
  color: var(--accent);
  font-size: 14px;
}

.file-list {
  display: grid;
  gap: 6px;
}

.empty,
.error,
.notice {
  border-radius: 6px;
  padding: 12px;
}

.empty {
  border: 1px dashed var(--line);
  color: var(--muted);
  text-align: center;
}

.error {
  background: #fff1f0;
  color: var(--danger);
}

.notice {
  background: #ecfdf3;
  color: #067647;
}

.settings-shell {
  display: grid;
  gap: 14px;
  max-width: 760px;
  padding: 18px;
}

.settings-panel {
  display: grid;
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 16px;
}

.settings-panel h1 {
  margin: 0;
  font-size: 18px;
}

.settings-form {
  display: grid;
  gap: 12px;
}

.settings-form.compact {
  grid-template-columns: minmax(140px, 1fr) minmax(160px, 1fr) auto;
  align-items: end;
}

.settings-form label {
  display: grid;
  gap: 6px;
  color: var(--muted);
}

.account-list {
  display: grid;
  gap: 10px;
}

.account-row {
  display: grid;
  gap: 8px;
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.token-box {
  overflow-wrap: anywhere;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f8fafc;
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-size: 13px;
  padding: 10px 12px;
}

.login-page {
  display: grid;
  place-items: center;
  padding: 20px;
}

.login-shell {
  width: min(100%, 380px);
}

.login-panel {
  display: grid;
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 22px;
}

.login-panel h1 {
  margin: 0;
  font-size: 22px;
}

.login-panel label {
  display: grid;
  gap: 6px;
  color: var(--muted);
}

@media (max-width: 720px) {
  .workspace {
    grid-template-columns: 1fr;
  }

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

  .category-list {
    display: flex;
    overflow-x: auto;
    padding-bottom: 2px;
  }

  .category-list a {
    flex: 0 0 auto;
  }

  .content {
    padding: 14px;
  }

  .message-list {
    grid-template-columns: minmax(0, 1fr);
  }

  .message-item {
    width: 100%;
    max-width: 300px;
  }

  .settings-form.compact {
    grid-template-columns: 1fr;
  }
}
