:root {
  color-scheme: dark;
  --panel-width: 280px;
  --bg: #0a0b0d;
  --panel: #111316;
  --panel-raised: #171a1f;
  --line: #282c33;
  --line-strong: #3a404a;
  --text: #f4f6f8;
  --muted: #858b96;
  --faint: #545a64;
  --accent: #9cffb7;
  --accent-soft: rgba(156, 255, 183, 0.1);
  --danger: #ff7d82;
  --radius: 5px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
}

button,
input,
select {
  font: inherit;
}

button {
  color: inherit;
}

.app-shell {
  display: flex;
  width: 100vw;
  height: 100vh;
  background: var(--bg);
}

.control-panel {
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  width: var(--panel-width);
  min-width: var(--panel-width);
  height: 100%;
  overflow: hidden;
  border-right: 1px solid var(--line);
  background: var(--panel);
  transition: width 180ms ease, min-width 180ms ease;
}

.app-shell.is-collapsed .control-panel {
  width: 0;
  min-width: 0;
  border-right-color: transparent;
}

.panel-header,
.link-list,
.panel-bottom,
.create-drawer {
  width: var(--panel-width);
}

.panel-bottom {
  position: relative;
  border-top: 1px solid var(--line);
  background: var(--panel);
}

.panel-actions {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 10px 12px;
}

.panel-actions .new-link-button,
.panel-actions .new-project-button {
  width: 100%;
}

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

.brand-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.header-actions {
  display: flex;
  gap: 6px;
  flex: 0 0 auto;
}

.auth-screen {
  display: grid;
  place-items: center;
  width: 100vw;
  height: 100vh;
  padding: 24px;
  background: var(--bg);
}

.auth-card {
  width: min(100%, 360px);
  padding: 22px 20px 20px;
  border: 1px solid var(--line);
  border-radius: calc(var(--radius) + 2px);
  background: var(--panel);
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 18px;
}

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-bottom: 14px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #0d0f12;
}

.auth-tab {
  height: 32px;
  border: 0;
  border-radius: calc(var(--radius) - 1px);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 11px;
  font-weight: 650;
  transition: background 140ms ease, color 140ms ease;
}

.auth-tab.is-active {
  background: var(--panel-raised);
  color: var(--text);
}

.auth-form {
  display: grid;
  gap: 10px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.brand-mark {
  display: grid;
  grid-template-columns: repeat(2, 5px);
  gap: 3px;
  flex: 0 0 auto;
}

.brand-mark span {
  width: 5px;
  height: 5px;
  background: var(--text);
}

.brand-mark span:last-child {
  background: var(--accent);
}

.brand-copy {
  min-width: 0;
}

.brand-title {
  margin: 0;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.brand-caption {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 0.03em;
}

.icon-button,
.new-link-button,
.new-project-button,
.edit-button {
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: transparent;
  cursor: pointer;
  transition: border-color 140ms ease, background 140ms ease, color 140ms ease;
}

.icon-button {
  width: 31px;
  height: 31px;
}

.icon-button:hover,
.new-link-button:hover,
.new-project-button:hover {
  border-color: var(--line-strong);
  background: var(--panel-raised);
}

.toolbar {
  margin-bottom: 10px;
}

.project-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.select-wrap,
.search-wrap {
  position: relative;
}

.select-wrap::after {
  position: absolute;
  top: 50%;
  right: 11px;
  width: 5px;
  height: 5px;
  border-right: 1px solid var(--muted);
  border-bottom: 1px solid var(--muted);
  content: "";
  pointer-events: none;
  transform: translateY(-70%) rotate(45deg);
}

select,
.search-input,
.form-input {
  width: 100%;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  outline: none;
  background: #0d0f12;
  color: var(--text);
  transition: border-color 140ms ease, box-shadow 140ms ease;
}

select {
  appearance: none;
  padding: 0 30px 0 11px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
}

.new-link-button,
.new-project-button {
  grid-template-columns: auto auto;
  justify-content: center;
  gap: 7px;
  height: 36px;
  padding: 0 11px;
  color: var(--text);
  font-size: 11px;
  font-weight: 650;
  white-space: nowrap;
}

.new-link-button[aria-expanded="true"],
.new-project-button[aria-expanded="true"] {
  border-color: rgba(156, 255, 183, 0.45);
  background: var(--accent-soft);
  color: var(--accent);
}

.form-select {
  padding: 0 30px 0 11px;
  cursor: pointer;
  font-size: 11px;
  font-weight: 600;
}

.search-icon {
  position: absolute;
  top: 50%;
  left: 11px;
  width: 12px;
  height: 12px;
  border: 1.5px solid var(--muted);
  border-radius: 50%;
  pointer-events: none;
  transform: translateY(-55%);
}

.search-icon::after {
  position: absolute;
  right: -4px;
  bottom: -3px;
  width: 5px;
  height: 1.5px;
  background: var(--muted);
  content: "";
  transform: rotate(45deg);
  transform-origin: left center;
}

.search-input {
  padding: 0 32px 0 33px;
  font-size: 12px;
}

.search-input::-webkit-search-cancel-button {
  filter: invert(0.65);
}

select:focus,
.search-input:focus,
.form-input:focus {
  border-color: rgba(156, 255, 183, 0.62);
  box-shadow: 0 0 0 3px rgba(156, 255, 183, 0.07);
}

.link-list {
  min-height: 0;
  margin: 0;
  padding: 10px 9px 18px;
  overflow-y: auto;
  overscroll-behavior: contain;
  list-style: none;
  scrollbar-color: var(--line-strong) transparent;
  scrollbar-width: thin;
}

.link-list::-webkit-scrollbar {
  width: 6px;
}

.link-list::-webkit-scrollbar-track {
  background: transparent;
}

.link-list::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: var(--line-strong);
}

.list-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 5px 8px 9px;
  color: var(--faint);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.list-meta-label {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
}

.list-meta-actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.list-meta-edit {
  width: 22px;
  height: 22px;
  opacity: 0.55;
  transform: none;
}

.list-meta-edit:hover,
.list-meta-edit:focus-visible {
  opacity: 1;
}

.link-item {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  /* min-height: 56px; */
  /* margin-bottom: 3px; */
  overflow: hidden;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: transparent;
  cursor: pointer;
  transition: background 120ms ease, border-color 120ms ease;
}

.link-item::before {
  position: absolute;
  top: 8px;
  bottom: 8px;
  left: 0;
  width: 2px;
  background: transparent;
  content: "";
}

.link-item:hover {
  border-color: var(--line);
  background: var(--panel-raised);
}

.link-item.is-active {
  border-color: rgba(156, 255, 183, 0.16);
  background: var(--accent-soft);
}

.link-item.is-active::before {
  background: var(--accent);
}

.link-content {
  min-width: 0;
  padding: 10px 8px 10px 13px;
}

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

.link-title {
  max-inline-size: 22ch;
  color: #e8eaed;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.link-domain {
  max-inline-size: 26ch;
  /* margin-top: 5px; */
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 9px;
}

.link-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  margin-right: 4px;
}

.open-tab-button,
.edit-button {
  width: 28px;
  height: 28px;
  border-color: transparent;
  color: var(--muted);
  opacity: 0;
  transform: translateX(4px);
  transition: opacity 120ms ease, transform 120ms ease, color 120ms ease, background 120ms ease;
}

.link-item:hover .open-tab-button,
.link-item:hover .edit-button,
.open-tab-button:focus-visible,
.edit-button:focus-visible {
  opacity: 1;
  transform: translateX(0);
}

.open-tab-button:hover {
  background: rgba(156, 255, 183, 0.1);
  color: var(--accent);
}

.edit-button:hover {
  background: var(--panel-raised);
  color: var(--text);
}

.project-group-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 2px;
}

.project-group-header .project-group-toggle {
  min-width: 0;
}

.project-group-header .edit-button {
  flex-shrink: 0;
  margin-right: 4px;
  opacity: 0;
}

.project-group-header:hover .edit-button,
.project-group-header .edit-button:focus-visible {
  opacity: 1;
  transform: translateX(0);
}

.empty-list {
  display: grid;
  min-height: 180px;
  place-items: center;
  padding: 24px;
  color: var(--muted);
  text-align: center;
  font-size: 11px;
  line-height: 1.6;
}

.project-group {
  margin-bottom: 4px;
}

.project-group-toggle {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 40px;
  padding: 8px 10px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: transparent;
  color: var(--text);
  cursor: pointer;
  text-align: left;
  transition: background 120ms ease, border-color 120ms ease;
}

.project-group-toggle:hover,
.project-group-toggle:focus-visible {
  border-color: var(--line);
  background: var(--panel-raised);
  outline: none;
}

.project-group-toggle[aria-expanded="true"] {
  border-color: rgba(156, 255, 183, 0.16);
  background: rgba(156, 255, 183, 0.04);
}

.project-folder-icon {
  display: inline-grid;
  place-items: center;
  color: var(--muted);
}

.project-group-toggle[aria-expanded="true"] .project-folder-icon {
  color: var(--accent);
}

.project-group-name {
  overflow: hidden;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.01em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.project-group-count {
  color: var(--faint);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.project-group-links {
  margin: 2px 0 6px;
  padding: 0 0 0 10px;
  list-style: none;
}

.create-drawer {
  position: absolute;
  right: 0;
  bottom: 100%;
  left: 0;
  z-index: 2;
  max-height: 0;
  overflow: hidden;
  border-top: 1px solid transparent;
  border-bottom: 1px solid transparent;
  background: #0d0f12;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.42);
  transition: max-height 220ms ease, border-color 220ms ease;
}

.create-drawer.is-open {
  max-height: 320px;
  border-top-color: var(--line);
  border-bottom-color: var(--line);
}

#createDrawer.is-open,
.create-drawer--link.is-open {
  max-height: 440px;
}

.create-form {
  display: grid;
  gap: 10px;
  padding: 15px 16px 17px;
}

.drawer-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1px;
}

.drawer-heading h2 {
  margin: 0;
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.drawer-close-button {
  width: 24px;
  height: 24px;
  flex-shrink: 0;
  color: var(--faint);
}

.drawer-close-button:hover {
  color: var(--text);
}

.form-field {
  display: grid;
  gap: 6px;
}

.form-field label {
  color: var(--muted);
  font-size: 9px;
  font-weight: 650;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.form-field--checkbox {
  margin-top: 2px;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0;
  text-transform: none;
  cursor: pointer;
}

.form-checkbox {
  width: 14px;
  height: 14px;
  margin: 0;
  accent-color: var(--accent);
  cursor: pointer;
}

.form-input {
  padding: 0 10px;
  font-size: 11px;
}

.submit-button {
  height: 37px;
  margin-top: 2px;
  border: 0;
  border-radius: var(--radius);
  background: var(--text);
  color: #0b0c0e;
  cursor: pointer;
  font-size: 11px;
  font-weight: 750;
  letter-spacing: 0.02em;
  transition: background 140ms ease, transform 140ms ease;
}

.submit-button:hover {
  background: var(--accent);
}

.submit-button:active {
  transform: translateY(1px);
}

.submit-button:disabled {
  cursor: wait;
  opacity: 0.55;
}

.delete-button {
  height: 37px;
  border: 1px solid rgba(255, 125, 130, 0.35);
  border-radius: var(--radius);
  background: transparent;
  color: var(--danger);
  cursor: pointer;
  font-size: 11px;
  font-weight: 650;
  transition: background 140ms ease, border-color 140ms ease;
}

.delete-button:hover {
  background: rgba(255, 125, 130, 0.08);
  border-color: rgba(255, 125, 130, 0.55);
}

.delete-button:disabled {
  cursor: wait;
  opacity: 0.55;
}

.url-field-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.paste-button {
  height: 36px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-raised);
  color: var(--text);
  cursor: pointer;
  font-size: 11px;
  font-weight: 650;
  white-space: nowrap;
}

.paste-button:hover {
  border-color: var(--line-strong);
  background: #1c2026;
}

.app-shell--mobile {
  display: block;
  width: 100%;
  min-height: 100vh;
  min-height: 100dvh;
}

.app-shell--mobile .control-panel {
  width: 100%;
  min-width: 0;
  max-width: 480px;
  margin: 0 auto;
  border-right: none;
  min-height: 100vh;
  min-height: 100dvh;
}

.app-shell--mobile .panel-header,
.app-shell--mobile .link-list,
.app-shell--mobile .panel-bottom,
.app-shell--mobile .create-drawer {
  width: 100%;
}

.link-item--touch .open-tab-button,
.link-item--touch .edit-button,
.project-group-header .edit-button {
  opacity: 1;
  transform: none;
}

.open-tab-button,
.edit-button,
.icon-button {
  min-width: 44px;
  min-height: 44px;
}

.link-title {
  max-inline-size: none;
}

.link-domain {
  max-inline-size: none;
}

html,
body {
  overflow: auto;
}

.toast {
  left: 16px;
  right: 16px;
  bottom: calc(16px + env(safe-area-inset-bottom));
  max-width: none;
}

.workspace {
  position: relative;
  min-width: 0;
  flex: 1;
  height: 100%;
  background:
    linear-gradient(rgba(255, 255, 255, 0.018) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.018) 1px, transparent 1px),
    var(--bg);
  background-size: 32px 32px;
}

.workspace-frame {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
  background: #fff;
  opacity: 0;
  pointer-events: none;
}

.workspace.has-frame .workspace-frame {
  opacity: 1;
  pointer-events: auto;
}

.workspace.has-frame .fallback {
  display: none;
}

.fallback {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: grid;
  place-items: center;
  padding: 40px;
}

.fallback-content {
  max-width: 420px;
  text-align: center;
}

.fallback-glyph {
  position: relative;
  width: 48px;
  height: 48px;
  margin: 0 auto 22px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
}

.fallback-glyph::before,
.fallback-glyph::after {
  position: absolute;
  content: "";
}

.fallback-glyph::before {
  inset: 10px;
  border: 1px solid var(--line);
}

.fallback-glyph::after {
  right: -4px;
  bottom: -4px;
  width: 9px;
  height: 9px;
  background: var(--accent);
  box-shadow: 0 0 0 4px var(--bg);
}

.fallback h1 {
  margin: 0;
  font-size: clamp(18px, 2vw, 25px);
  font-weight: 560;
  letter-spacing: -0.035em;
}

.fallback p {
  max-width: 340px;
  margin: 11px auto 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.6;
}

.collapse-handle {
  position: absolute;
  z-index: 4;
  top: 0px;
  left: calc(var(--panel-width));
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border: 1px solid rgba(40, 44, 51, 0.5);
  /* border-radius: var(--radius); */
  background: rgba(17, 19, 22, 0.5);
  color: var(--muted);
  cursor: pointer;
  backdrop-filter: blur(2px);
  transition: left 180ms ease, color 140ms ease, border-color 140ms ease, background 140ms ease;
}

.app-shell.is-collapsed .collapse-handle {
  left: 12px;
}

.collapse-handle:hover {
  border-color: rgba(58, 64, 74, 0.75);
  background: rgba(17, 19, 22, 0.65);
  color: var(--text);
}

.collapse-handle svg {
  transition: transform 180ms ease;
}

.app-shell.is-collapsed .collapse-handle svg {
  transform: rotate(180deg);
}

.toast {
  position: fixed;
  z-index: 10;
  right: 18px;
  bottom: 18px;
  max-width: 360px;
  padding: 11px 13px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: #15181c;
  color: var(--text);
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.32);
  font-size: 11px;
  line-height: 1.4;
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition: opacity 160ms ease, transform 160ms ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.toast.is-error {
  border-color: rgba(255, 125, 130, 0.45);
  color: #ffc3c6;
}

@media (max-width: 680px) {
  :root {
    --panel-width: min(320px, calc(100vw - 48px));
  }

  .control-panel {
    position: absolute;
    inset: 0 auto 0 0;
    box-shadow: 20px 0 60px rgba(0, 0, 0, 0.28);
  }

  .app-shell.is-collapsed .control-panel {
    box-shadow: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
