:root {
  --bg: #F7F2E9;
  --bg-card: #FFFDF8;
  --bg-header: #FBF6EC;
  --border: #E5D9C2;
  --border-input: #D9CCB4;
  --text: #3D3528;
  --text-muted: #7A6E5C;
  --text-faint: #A89B85;
  --accent: #B5651D;
  --accent-green: #4A6741;
  --accent-red: #A8324A;
  --accent-gold: #D9A521;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Iowan Old Style', 'Palatino Linotype', Georgia, serif;
}

input, textarea, select, button {
  font-family: system-ui, -apple-system, sans-serif;
}

input, textarea, select {
  border: 1px solid var(--border-input);
  border-radius: 6px;
  padding: 9px 12px;
  background: var(--bg-card);
  color: var(--text);
  font-size: 15px;
  width: 100%;
}

label {
  font-size: 12.5px;
  color: #8A7D68;
  font-weight: 600;
  display: block;
  margin: 10px 0 4px;
  font-family: system-ui, sans-serif;
}

.topbar {
  background: var(--bg-header);
  border-bottom: 1px solid var(--border);
  padding: 18px 20px;
}
.topbar-inner {
  max-width: 920px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.brand-title { font-size: 24px; font-weight: 700; }
.brand-count { font-family: system-ui, sans-serif; font-size: 13px; color: var(--text-faint); margin-left: 10px; }
.user-box { display: flex; align-items: center; gap: 12px; font-family: system-ui, sans-serif; font-size: 14px; color: var(--text-muted); }

.btn-primary, .btn-secondary, .btn-ghost, .btn-icon {
  cursor: pointer;
  border: none;
  font-weight: 600;
  border-radius: 8px;
  font-family: system-ui, sans-serif;
}
.btn-primary { background: var(--accent); color: #FFF8EE; padding: 9px 16px; font-size: 14.5px; }
.btn-secondary { background: var(--bg-card); color: var(--text-muted); border: 1px solid var(--border-input); padding: 9px 14px; font-size: 14.5px; }
.btn-ghost { background: transparent; color: var(--text-faint); padding: 4px 8px; text-decoration: underline; font-size: 13px; }
.btn-icon { background: transparent; color: var(--text-faint); font-size: 18px; padding: 2px 8px; }

.login-screen {
  min-height: 80vh;
  display: flex;
  align-items: center;
  justify-content: center;
}
.login-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 32px;
  width: 320px;
}
.login-card h2 { margin: 0 0 6px; font-size: 20px; }
.error-text { color: var(--accent-red); font-size: 13.5px; font-family: system-ui, sans-serif; margin-top: 8px; }
.warning-text { color: #8A5A1E; background: #FBEFE0; padding: 8px 10px; border-radius: 6px; font-size: 13px; font-family: system-ui, sans-serif; }
.hint-text { color: var(--text-muted); font-size: 13.5px; font-family: system-ui, sans-serif; }

.app-main { max-width: 920px; margin: 0 auto; padding: 20px; }

.toolbar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 16px;
  font-family: system-ui, sans-serif;
}
.search-box { flex: 1 1 200px; min-width: 180px; }
.toolbar select { width: auto; min-width: 130px; }
#addBtn { margin-left: auto; }

.links-list { display: flex; flex-direction: column; gap: 10px; }
.link-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  display: flex;
  justify-content: space-between;
  gap: 10px;
}
.link-main { flex: 1; min-width: 0; font-family: system-ui, sans-serif; }
.link-title-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 5px; }
.link-title-row a { color: var(--text); font-weight: 600; font-size: 14.5px; text-decoration: none; word-break: break-all; }
.chips-row { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 6px; }
.chip { border-radius: 999px; padding: 4px 11px; font-size: 12.5px; font-weight: 600; }
.link-comment { margin: 0; font-size: 13.5px; color: var(--text-muted); line-height: 1.4; }
.link-actions { display: flex; gap: 4px; flex-shrink: 0; }
.link-actions button { background: transparent; padding: 6px; border-radius: 6px; font-size: 15px; }
.empty-state { padding: 48px 24px; text-align: center; color: var(--text-faint); font-family: system-ui, sans-serif; background: var(--bg-card); border-radius: 10px; border: 1px solid var(--border); }

.modal-overlay {
  position: fixed; inset: 0; background: rgba(61,53,40,0.45);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 24px 16px; overflow-y: auto; z-index: 50;
}
.modal-card {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: 10px;
  max-width: 480px; width: 100%; padding: 22px; margin-top: 16px;
}
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.modal-header h2 { margin: 0; font-size: 19px; }
.form-row { display: flex; gap: 10px; }
.form-row > div { flex: 1; }
.form-actions { display: flex; gap: 10px; margin-top: 16px; }
.star-rating { display: flex; gap: 4px; }
.star-rating span { cursor: pointer; font-size: 20px; color: var(--border-input); }
.star-rating span.filled { color: var(--accent-gold); }

.file-drop {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  border: 2px dashed var(--border-input); border-radius: 10px; padding: 28px 16px;
  cursor: pointer; background: var(--bg-header); margin-top: 8px; font-family: system-ui, sans-serif;
  font-weight: 600; color: var(--text-muted); font-size: 14px;
}

@media (max-width: 640px) {
  #addBtn { margin-left: 0; width: 100%; }
  .toolbar { flex-direction: column; align-items: stretch; }
  .toolbar select { width: 100%; }
}
