:root {
  --bg: #e9eee3;
  --paper: #f8fbf3;
  --panel: #ffffff;
  --ink: #172218;
  --muted: #5f6a5f;
  --line: #c8d3c2;
  --accent: #ff7a18;
  --accent-dark: #df6408;
  --signal: #0ea56f;
  --signal-soft: #e3f6ee;
  --danger: #c62828;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --bottom-nav-height: 56px;
  --bottom-nav-offset: 14px;
  --bottom-nav-offset-mobile: 0px;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: "IBM Plex Sans KR", "JetBrains Mono", "SF Mono", "Consolas", monospace;
  background:
    linear-gradient(90deg, rgba(23, 34, 24, 0.03) 1px, transparent 1px) 0 0 / 24px 24px,
    linear-gradient(rgba(23, 34, 24, 0.03) 1px, transparent 1px) 0 0 / 24px 24px,
    var(--bg);
  color: var(--ink);
}

body.modal-open {
  overflow: hidden;
}

a {
  color: inherit;
}

a,
button,
input,
label {
  touch-action: manipulation;
}

.app-shell {
  width: min(1180px, 96vw);
  margin: 14px auto 32px;
  background: var(--paper);
  border: 1px solid var(--line);
  box-shadow: 0 30px 70px rgba(12, 26, 15, 0.12);
}

.hero {
  background: #1d3122;
  color: #eff7ea;
  padding: 10px 14px;
  border-bottom: 2px solid var(--accent);
}

.topline {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.logo-box {
  min-width: 36px;
  height: 22px;
  border: 1px solid rgba(255, 255, 255, 0.85);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  text-decoration: none;
  color: #fff;
}

.eyebrow {
  margin: 0;
  font-size: 11px;
  letter-spacing: 0.08em;
  font-weight: 700;
  color: #d7ead9;
}

.panel {
  padding: 13px 14px;
  border-top: 1px solid #d8e2d2;
}

.panel-head h2,
.card-head h3,
.form-card h3 {
  margin: 0;
  font-size: 13px;
  font-weight: 700;
}

.panel-head p,
.small {
  margin: 4px 0 0;
  font-size: 11px;
  color: var(--muted);
}

.grid {
  display: grid;
  gap: 12px;
}

.auth-grid {
  margin-top: 10px;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

.form-card {
  border: 1px solid var(--line);
  background: var(--panel);
  padding: 10px;
  display: grid;
  gap: 8px;
  box-shadow: inset 0 0 0 1px #edf3e8;
}

label {
  display: grid;
  gap: 4px;
  font-size: 12px;
}

input {
  width: 100%;
  padding: 8px 9px;
  border: 1px solid #afbbab;
  border-radius: 0;
  background: #fefefa;
  color: var(--ink);
  font: inherit;
  font-size: 12px;
}

input:focus {
  outline: 1px solid var(--signal);
  border-color: var(--signal);
}

.btn {
  border: 1px solid #9ba897;
  border-radius: 0;
  background: #ecf2e7;
  color: #121d13;
  font: inherit;
  font-size: 11px;
  font-weight: 700;
  padding: 7px 10px;
  cursor: pointer;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.btn:hover {
  background: #dfead8;
  border-color: #879383;
}

.btn.secondary {
  background: #fff6ef;
  border-color: var(--accent);
  color: #65320d;
}

.btn.secondary:hover {
  background: #ffeede;
  border-color: var(--accent-dark);
}

.btn.ghost {
  background: transparent;
}

.btn.tiny {
  font-size: 10px;
  padding: 4px 7px;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.app-panel {
  display: grid;
  gap: 10px;
  padding-bottom: calc(
    var(--bottom-nav-height) + var(--safe-bottom) + var(--bottom-nav-offset) + 18px
  );
}

.app-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.app-topbar p {
  margin: 0;
  font-size: 12px;
  color: #435545;
}

.view-stack {
  min-height: 340px;
}

.view {
  display: none;
}

.view.is-active {
  display: block;
}

.submit-focus {
  border: 1px solid #bfd0b9;
  background: linear-gradient(180deg, #f6fff8 0%, #eef8f2 100%);
  padding: 14px;
  box-shadow: inset 0 0 0 1px #e0ebe2;
}

.submit-title {
  margin: 0 0 10px;
  font-size: 16px;
}

.spotlight-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(220px, 0.6fr) auto;
  gap: 8px;
  align-items: end;
}

.spotlight-url input,
.spotlight-note input,
.submit-main {
  height: 48px;
}

.spotlight-url input {
  font-size: 16px;
  font-weight: 600;
  border-color: #90aa97;
}

.submit-main {
  border-color: var(--accent-dark);
  background: var(--accent);
  color: #fffbf4;
  padding: 0 16px;
}

.submit-main:hover {
  background: #e0690d;
  border-color: #c85908;
}

.focus-hint {
  margin: 8px 0 0;
  font-size: 11px;
  color: #4a5f4c;
}

.card {
  border: 1px solid var(--line);
  background: #fbfdf9;
  padding: 10px;
  position: relative;
}

.card::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: linear-gradient(to bottom, var(--signal), var(--accent));
}

.card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  border-bottom: 1px solid #e4ecde;
  padding-bottom: 6px;
  margin-bottom: 6px;
}

.tabs {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 4px;
}

.tab {
  border: 1px solid transparent;
  border-radius: 0;
  background: transparent;
  color: var(--muted);
  padding: 2px 6px;
  font: inherit;
  font-size: 10px;
  cursor: pointer;
  text-transform: uppercase;
}

.tab:hover {
  color: #132117;
}

.tab.is-active {
  border-color: #b9c7b2;
  background: var(--signal-soft);
  color: #0f4f36;
  font-weight: 700;
}

.list {
  list-style: none;
  padding: 0;
  margin: 0;
  counter-reset: row;
}

.item {
  counter-increment: row;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  padding: 8px 0;
  border-bottom: 1px dashed #d4ddcf;
}

.item:last-child {
  border-bottom: none;
}

.item-main {
  min-width: 0;
}

.item-main a {
  text-decoration: none;
  font-size: 12px;
  word-break: break-word;
}

.item-main a::before {
  content: counter(row) ". ";
  color: var(--accent-dark);
  font-weight: 700;
}

.item-main a:hover {
  text-decoration: underline;
}

.meta {
  margin: 2px 0 0;
  font-size: 10px;
  color: var(--muted);
}

.submeta {
  margin: 2px 0 0;
  font-size: 10px;
  color: #6d786d;
}

.summary {
  margin: 4px 0 0;
  font-size: 11px;
  color: #465546;
  line-height: 1.35;
}

.note {
  margin: 3px 0 0;
  font-size: 11px;
  color: #3f4d40;
}

.url-meta {
  margin: 4px 0 0;
  font-size: 10px;
  color: #7b877b;
  word-break: break-all;
}

.item-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  justify-content: flex-end;
}

.empty {
  border: 1px dashed #c8d3c2;
  background: #f9fdf6;
  color: var(--muted);
  font-size: 11px;
  text-align: center;
  padding: 10px 8px;
}

.token-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.token-box {
  margin: 8px 0 0;
  border: 1px dashed #b5c2af;
  background: #f9fff5;
  padding: 8px;
  font-family: "IBM Plex Mono", "JetBrains Mono", "Courier New", monospace;
  font-size: 10px;
  color: #304b33;
  white-space: pre-wrap;
  word-break: break-all;
}

.install-row {
  margin-top: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.guide-row {
  margin-top: 10px;
  display: grid;
  gap: 6px;
}

.hint {
  margin: 0;
  font-size: 11px;
  color: #4a5f4c;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(18, 24, 19, 0.46);
  display: grid;
  align-items: center;
  justify-items: center;
  padding: 14px;
}

.modal-card {
  width: min(560px, calc(100vw - 20px));
  max-height: min(82vh, 760px);
  overflow: auto;
  border: 1px solid #b8c7b2;
  background: #f7fcf3;
  box-shadow: 0 18px 50px rgba(7, 20, 11, 0.35);
  padding: 12px;
}

.modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.modal-head h3 {
  margin: 0;
  font-size: 14px;
}

.guide-steps {
  margin: 10px 0 0;
  padding-left: 18px;
  display: grid;
  gap: 8px;
  font-size: 12px;
  line-height: 1.4;
}

.guide-steps strong {
  font-weight: 700;
}

.guide-steps code {
  font-family: "IBM Plex Mono", "JetBrains Mono", "Courier New", monospace;
  font-size: 11px;
  background: #edf4e8;
  border: 1px solid #c9d6c4;
  padding: 1px 4px;
}

.modal-actions {
  margin-top: 12px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.bottom-nav {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(var(--safe-bottom) + var(--bottom-nav-offset));
  z-index: 10;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
  width: min(1180px, 96vw);
  padding: 8px;
  background: #f3f8ef;
  border: 1px solid var(--line);
  box-shadow: 0 -6px 18px rgba(12, 26, 15, 0.08);
}

.bottom-tab {
  border: 1px solid #b7c5b1;
  background: #ecf3e7;
  color: #3a4b3a;
  font: inherit;
  font-size: 11px;
  font-weight: 700;
  padding: 8px 6px;
  text-transform: uppercase;
  cursor: pointer;
}

.bottom-tab.is-active {
  border-color: var(--accent);
  background: #fff5ec;
  color: #64310d;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--safe-bottom) + var(--bottom-nav-offset) + var(--bottom-nav-height) + 14px);
  transform: translateX(-50%);
  z-index: 20;
  background: #223125;
  color: #e7f9e8;
  border: 1px solid #0f170f;
  padding: 7px 11px;
  font-size: 11px;
}

.toast[data-type="error"] {
  background: var(--danger);
  color: #fff;
}

@media (max-width: 1050px) {
  .spotlight-form {
    grid-template-columns: 1fr 1fr;
  }

  .submit-main {
    grid-column: 1 / -1;
  }
}

@media (max-width: 760px) {
  .app-shell {
    width: 100%;
    margin: 0;
    border-left: none;
    border-right: none;
  }

  .panel {
    padding: 11px 10px;
  }

  .app-panel {
    padding-bottom: calc(var(--bottom-nav-height) + var(--safe-bottom) + 28px);
  }

  .bottom-nav {
    left: 0;
    transform: none;
    width: 100%;
    bottom: 0;
    gap: 8px;
    padding: 8px 10px calc(var(--safe-bottom) + 10px);
    border-left: none;
    border-right: none;
    border-bottom: none;
    background: rgba(243, 248, 239, 0.94);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    box-shadow: 0 -10px 22px rgba(12, 26, 15, 0.13);
  }

  .bottom-tab {
    min-height: 40px;
    padding: 8px 4px;
    font-size: 10px;
    letter-spacing: 0.03em;
  }

  .toast {
    bottom: calc(var(--safe-bottom) + var(--bottom-nav-height) + 24px);
  }

  .app-topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .modal-backdrop {
    align-items: end;
    padding: 8px;
  }

  .modal-card {
    width: 100%;
    max-height: min(88vh, 900px);
    border-radius: 8px 8px 0 0;
    border-bottom: none;
  }

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

  .spotlight-url input,
  .spotlight-note input,
  .submit-main {
    height: 44px;
  }

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

  .item-actions {
    justify-content: flex-start;
  }
}
