:root {
  color-scheme: dark;
  --bg: #111314;
  --panel: #1c2022;
  --panel-strong: #24292b;
  --panel-soft: #151718;
  --line: #343a3d;
  --line-strong: #4d5559;
  --text: #f7f9f9;
  --muted: #a5b0b5;
  --faint: #748087;
  --accent: #22a8e8;
  --accent-strong: #45c0ff;
  --warn: #f7ef3f;
  --danger: #ff685f;
  --success: #54d186;
  --radius: 8px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
}

button,
input,
textarea {
  font: inherit;
}

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

.shell {
  display: grid;
  grid-template-columns: minmax(310px, 360px) minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  display: flex;
  min-height: 100vh;
  flex-direction: column;
  border-right: 1px solid var(--line);
  background: var(--panel);
}

.sidebar-header,
.detail-header {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 18px 22px;
}

.sidebar-header {
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
}

.eyebrow {
  margin: 0 0 3px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

h1,
h2,
h3 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: 24px;
}

h2 {
  font-size: 22px;
}

h3 {
  font-size: 16px;
}

.list-tools {
  display: grid;
  gap: 12px;
  padding: 16px 22px;
  border-bottom: 1px solid var(--line);
}

.search-field input,
label input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #080909;
  color: var(--text);
  outline: none;
}

.search-field input {
  height: 42px;
  padding: 0 13px;
}

label input {
  height: 40px;
  padding: 0 12px;
}

textarea {
  min-height: 86px;
  padding: 11px 12px;
  resize: vertical;
}

input:focus,
textarea:focus {
  border-color: var(--accent-strong);
  box-shadow: 0 0 0 2px rgba(34, 168, 232, 0.18);
}

.archive-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 14px;
}

.archive-toggle input {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
}

.status-line {
  min-height: 35px;
  padding: 11px 22px 0;
  color: var(--muted);
  font-size: 13px;
}

.link-list {
  display: grid;
  gap: 6px;
  overflow-y: auto;
  padding: 12px;
}

.link-row {
  display: grid;
  gap: 8px;
  width: 100%;
  min-height: 108px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: transparent;
  color: var(--text);
  padding: 14px 14px 14px 18px;
  text-align: left;
  cursor: pointer;
}

.link-row:hover {
  border-color: var(--line);
  background: rgba(255, 255, 255, 0.025);
}

.link-row.active {
  border-color: var(--line-strong);
  background: var(--panel-soft);
  box-shadow: inset 4px 0 0 var(--accent);
}

.link-row.archived {
  opacity: 0.64;
}

.link-slug {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-weight: 800;
}

.archive-pill {
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  padding: 3px 7px;
  text-transform: uppercase;
}

.link-meta {
  display: grid;
  gap: 2px;
  color: var(--muted);
  font-size: 13px;
}

.link-meta strong {
  display: block;
  overflow: hidden;
  color: var(--text);
  font-size: 14px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.detail {
  min-width: 0;
  background: var(--bg);
}

.detail-header {
  min-height: 86px;
  border-bottom: 1px solid var(--line);
}

.brand-mark {
  display: grid;
  width: 32px;
  height: 32px;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid #d8dfd2;
  background: #f3f6ed;
  color: #45513c;
  font-size: 12px;
  font-weight: 900;
}

.detail-title {
  min-width: 0;
  flex: 1;
}

.detail-title h2 {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.detail-actions,
.form-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.editor-form {
  display: grid;
  gap: 22px;
  max-width: 900px;
  padding: 24px 32px 32px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.utm-section {
  display: grid;
  gap: 18px;
  border-top: 1px solid var(--line);
  padding-top: 22px;
}

.section-heading {
  display: flex;
  align-items: center;
  gap: 11px;
}

.tool-chip {
  display: grid;
  min-width: 44px;
  height: 32px;
  place-items: center;
  border-radius: var(--radius);
  background: var(--warn);
  color: #111314;
  font-size: 12px;
  font-weight: 900;
}

.message {
  min-height: 24px;
  color: var(--muted);
  font-size: 14px;
}

.message.error {
  color: var(--danger);
}

.message.success {
  color: var(--success);
}

.form-actions {
  justify-content: flex-end;
  border-top: 1px solid var(--line);
  padding-top: 20px;
}

.primary-button,
.secondary-button,
.danger-button,
.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  color: var(--text);
  cursor: pointer;
  font-weight: 800;
  text-decoration: none;
}

.primary-button,
.secondary-button,
.danger-button {
  min-height: 40px;
  padding: 0 15px;
}

.icon-button {
  width: 40px;
  height: 40px;
  background: var(--panel-soft);
  font-size: 24px;
}

.primary-button,
.icon-button.primary {
  border-color: var(--accent);
  background: var(--accent);
  color: #071116;
}

.secondary-button {
  background: var(--panel-soft);
}

.danger-button {
  border-color: rgba(255, 104, 95, 0.55);
  background: rgba(255, 104, 95, 0.1);
  color: #ffd4d1;
}

.primary-button:disabled,
.secondary-button:disabled,
.danger-button:disabled,
.disabled {
  opacity: 0.45;
  pointer-events: none;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

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

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

  .link-list {
    max-height: 42vh;
  }

  .detail-header {
    align-items: flex-start;
    flex-wrap: wrap;
  }

  .detail-actions {
    width: 100%;
  }

  .editor-form {
    padding: 20px;
  }

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

  .form-actions {
    align-items: stretch;
    flex-direction: column-reverse;
  }

  .form-actions button {
    width: 100%;
  }
}
