:root {
  color-scheme: light;
  --bg: #f6f7f4;
  --surface: #ffffff;
  --surface-muted: #eef3ed;
  --text: #1f2523;
  --muted: #65706b;
  --line: #dce4de;
  --accent: #116149;
  --accent-strong: #0b4c39;
  --accent-soft: #dceee7;
  --danger: #b3261e;
  --shadow: 0 12px 30px rgba(21, 35, 29, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
}

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

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  width: min(100%, 860px);
  min-height: 100vh;
  margin: 0 auto;
  padding: 18px 16px 112px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 0 18px;
}

.home-link {
  display: inline-block;
  margin-bottom: 10px;
  color: var(--accent);
  font-size: 0.9rem;
  font-weight: 900;
  text-decoration: none;
}

.home-link:hover {
  color: var(--accent-strong);
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(1.8rem, 8vw, 3.6rem);
  line-height: 0.95;
}

h2 {
  font-size: 1.2rem;
}

.add-button,
.ghost-button {
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font-weight: 700;
}

.add-button {
  grid-auto-flow: column;
  gap: 7px;
  min-width: 94px;
  min-height: 44px;
  padding: 0 12px;
}

.add-button span {
  font-size: 1.25rem;
  line-height: 1;
}

.ghost-button {
  width: 44px;
  height: 44px;
  font-size: 1.5rem;
}

.folder-strip {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 8px 0 12px;
}

.folder-scroll {
  display: flex;
  flex: 1;
  gap: 8px;
  overflow-x: auto;
  padding: 2px 0 8px;
  scrollbar-width: none;
}

.folder-scroll::-webkit-scrollbar {
  display: none;
}

.folder-tab {
  flex: 0 0 auto;
  min-height: 38px;
  max-width: 180px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 14px;
  background: var(--surface);
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.folder-tab.active {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.text-button {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  background: var(--surface);
  color: var(--text);
  font-weight: 700;
}

.actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin: 8px 0 16px;
}

.primary-button,
.secondary-button,
.danger-button {
  min-height: 46px;
  border-radius: 8px;
  padding: 0 14px;
  font-weight: 800;
}

.primary-button {
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
}

.primary-button:active {
  background: var(--accent-strong);
}

.secondary-button {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
}

.danger-button {
  border: 1px solid rgba(179, 38, 30, 0.28);
  background: #fff5f4;
  color: var(--danger);
}

.current-folder {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  padding: 16px 0;
}

.current-folder p:last-child {
  color: var(--muted);
  font-weight: 700;
}

.folder-heading {
  display: flex;
  align-items: center;
  gap: 8px;
}

.folder-heading span {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px 8px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: 0.72rem;
  font-weight: 800;
  white-space: nowrap;
}

.url-list {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.url-card {
  display: grid;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.url-card-header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 10px;
}

.url-title {
  color: var(--text);
  font-size: 1rem;
  font-weight: 800;
  text-decoration: none;
  overflow-wrap: anywhere;
}

.url-value,
.url-meta {
  color: var(--muted);
  font-size: 0.86rem;
  overflow-wrap: anywhere;
}

.url-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.small-button {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
  background: var(--surface-muted);
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 700;
}

.small-button.favorite {
  border-color: #c69214;
  background: #fff6da;
}

.small-button.strong-action {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.empty-state {
  display: grid;
  justify-items: center;
  gap: 12px;
  padding: 30px 8px;
  color: var(--muted);
  text-align: center;
}

.empty-state .secondary-button {
  min-width: 140px;
}

.bottom-actions {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  width: min(100%, 860px);
  margin: 0 auto;
  border-top: 1px solid var(--line);
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
  background: rgba(246, 247, 244, 0.94);
  backdrop-filter: blur(14px);
}

.compact-button {
  min-width: 92px;
}

dialog {
  width: min(calc(100% - 28px), 520px);
  border: 0;
  border-radius: 8px;
  padding: 0;
  background: transparent;
}

dialog::backdrop {
  background: rgba(15, 21, 18, 0.46);
}

.dialog-card {
  display: grid;
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.dialog-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 800;
}

input,
select {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  background: #fff;
  color: var(--text);
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.checkbox-row input {
  width: 20px;
  min-height: 20px;
}

.dialog-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

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

.folder-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
}

.folder-row input {
  min-height: 38px;
}

.folder-row strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (max-width: 420px) {
  .folder-row {
    grid-template-columns: 1fr 1fr;
  }

  .folder-row input,
  .folder-row strong {
    grid-column: 1 / -1;
  }
}

.toast {
  position: fixed;
  right: 16px;
  bottom: 16px;
  left: 16px;
  z-index: 20;
  max-width: 520px;
  margin: 0 auto;
  border-radius: 8px;
  padding: 12px 14px;
  background: var(--text);
  color: #fff;
  font-weight: 700;
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition:
    opacity 160ms ease,
    transform 160ms ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

@media (min-width: 680px) {
  .app-shell {
    padding-top: 28px;
    padding-bottom: 40px;
  }

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

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

  .bottom-actions {
    display: none;
  }
}
