/* ========== 빈티지 캠코더 무드 ========== */
:root {
  --bg: #f4ebd9;
  --bg-card: #faf4e6;
  --bg-soft: #ede0c4;
  --ink: #2b2419;
  --ink-soft: #5a4a35;
  --accent: #c1462d;
  --accent-deep: #8a2e1a;
  --sepia: #8b7355;
  --border: #d4c5a0;
  --border-dark: #a08b5f;
  --good: #4d6b3a;
  --warn: #b8841f;
  --shadow: 0 2px 0 rgba(43, 36, 25, 0.08);
  --osd: 'VT323', 'Courier New', monospace;
  --body: 'Noto Sans KR', 'Inter', system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--body);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

button { font-family: inherit; cursor: pointer; }
input, textarea, button { font-family: inherit; color: inherit; }

/* CRT scanlines overlay (subtle) */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(
    0deg,
    rgba(43, 36, 25, 0.02) 0px,
    rgba(43, 36, 25, 0.02) 1px,
    transparent 1px,
    transparent 3px
  );
  z-index: 9999;
}

/* ========== TOP BAR ========== */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  background: var(--ink);
  color: var(--bg);
  border-bottom: 3px solid var(--accent);
}

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

.brand-name {
  font-family: var(--osd);
  font-size: 24px;
  letter-spacing: 2px;
  color: var(--bg);
}

.brand-sub {
  font-family: var(--osd);
  font-size: 16px;
  color: var(--border);
  letter-spacing: 1px;
}

.rec-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent);
  animation: blink 1.4s infinite;
}

@keyframes blink {
  0%, 60% { opacity: 1; }
  61%, 100% { opacity: 0.3; }
}

.top-meta {
  display: flex;
  align-items: center;
  gap: 16px;
}

.osd-text {
  font-family: var(--osd);
  font-size: 18px;
  color: var(--border);
  letter-spacing: 1px;
}

.key-status {
  background: transparent;
  color: var(--bg);
  border: 1px solid var(--border-dark);
  padding: 6px 12px;
  border-radius: 4px;
  font-size: 13px;
  transition: all 0.15s;
}

.key-status:hover { background: var(--accent); border-color: var(--accent); }
.key-status.is-set { border-color: var(--good); color: #c8e6b0; }

/* ========== LAYOUT ========== */
.main-wrap {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: calc(100vh - 60px);
}

.sidebar {
  background: var(--bg-soft);
  border-right: 2px solid var(--border-dark);
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.sidebar nav {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.tab-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  text-align: left;
  color: var(--ink-soft);
  font-size: 14px;
  font-weight: 500;
  transition: all 0.15s;
}

.tab-btn:hover {
  background: var(--bg-card);
  color: var(--ink);
}

.tab-btn.active {
  background: var(--ink);
  color: var(--bg);
  border-color: var(--accent);
}

.tab-icon { font-size: 18px; }

.sidebar-footer { margin-top: auto; }

.profile-box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 12px;
}

.profile-label {
  font-family: var(--osd);
  font-size: 14px;
  color: var(--sepia);
  letter-spacing: 1px;
  margin-bottom: 8px;
}

#creator-profile {
  width: 100%;
  min-height: 90px;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 8px;
  background: var(--bg);
  font-size: 12.5px;
  resize: vertical;
}

#creator-profile:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

.btn-mini {
  margin-top: 8px;
  padding: 6px 12px;
  background: var(--ink);
  color: var(--bg);
  border: none;
  border-radius: 4px;
  font-size: 12px;
}

.btn-mini:hover { background: var(--accent); }

/* ========== CONTENT ========== */
.content {
  padding: 32px 40px;
  max-width: 1100px;
}

.tab-panel { display: none; }
.tab-panel.active { display: block; animation: fadein 0.2s; }

@keyframes fadein {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: none; }
}

.panel-title {
  font-size: 24px;
  margin: 0 0 6px;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.panel-sub {
  color: var(--ink-soft);
  margin: 0 0 24px;
  font-size: 13.5px;
}

/* ========== FORM ========== */
.form-row {
  margin-bottom: 16px;
}

.form-row label {
  display: block;
  font-size: 13px;
  color: var(--sepia);
  margin-bottom: 6px;
  font-weight: 500;
}

.form-row input[type="text"] {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-card);
  font-size: 14px;
}

.form-row input[type="text"]:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

.action-row {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
}

.btn-primary {
  background: var(--accent);
  color: var(--bg);
  border: none;
  padding: 10px 20px;
  border-radius: 6px;
  font-weight: 600;
  font-size: 14px;
  transition: all 0.15s;
  box-shadow: var(--shadow);
}

.btn-primary:hover:not(:disabled) { background: var(--accent-deep); }
.btn-primary:disabled { opacity: 0.45; cursor: not-allowed; }

.btn-ghost {
  background: transparent;
  color: var(--ink-soft);
  border: 1px solid var(--border-dark);
  padding: 10px 16px;
  border-radius: 6px;
  font-size: 14px;
}

.btn-ghost:hover { background: var(--bg-card); color: var(--ink); }

.link-btn {
  background: none;
  border: none;
  color: var(--accent);
  text-decoration: underline;
  padding: 0;
  font-size: inherit;
}

/* ========== UPLOAD ========== */
.upload-box {
  border: 2px dashed var(--border-dark);
  border-radius: 10px;
  padding: 32px;
  text-align: center;
  background: var(--bg-card);
  margin-bottom: 16px;
  transition: all 0.15s;
  cursor: pointer;
}

.upload-box.dragover {
  border-color: var(--accent);
  background: #fff4e8;
}

.upload-icon { font-size: 38px; margin-bottom: 8px; }
.upload-text { font-size: 14px; margin-bottom: 6px; }
.upload-hint { font-size: 12px; color: var(--sepia); }

.preview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.preview-item {
  position: relative;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  aspect-ratio: 9 / 16;
  background: var(--bg-card);
}

.preview-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.preview-remove {
  position: absolute;
  top: 4px;
  right: 4px;
  background: rgba(0,0,0,0.7);
  color: white;
  border: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  font-size: 12px;
  line-height: 1;
}

/* ========== RESULT BOX ========== */
.result-box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0;
  min-height: 40px;
}

.result-box:empty { display: none; }

.result-section {
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
}
.result-section:last-child { border-bottom: none; }

.result-section h3 {
  margin: 0 0 8px;
  font-size: 15px;
  color: var(--accent-deep);
  font-family: var(--osd);
  letter-spacing: 1.5px;
  font-weight: 400;
}

.result-section ul { margin: 0; padding-left: 20px; }
.result-section li { margin-bottom: 4px; font-size: 13.5px; }
.result-section p { margin: 0 0 6px; font-size: 13.5px; }

.result-section.good h3 { color: var(--good); }
.result-section.warn h3 { color: var(--warn); }

/* ========== IDEAS GRID ========== */
.ideas-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.idea-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
  position: relative;
}

.idea-card .idea-num {
  font-family: var(--osd);
  font-size: 14px;
  color: var(--sepia);
  letter-spacing: 1px;
}

.idea-card .idea-title {
  font-size: 16px;
  font-weight: 700;
  margin: 4px 0 10px;
  line-height: 1.3;
}

.idea-card .idea-row {
  font-size: 12.5px;
  margin-bottom: 6px;
  color: var(--ink-soft);
}

.idea-card .idea-row b {
  color: var(--ink);
  font-weight: 600;
  margin-right: 4px;
}

.idea-card .idea-hashtags {
  margin-top: 10px;
  font-size: 12px;
  color: var(--accent-deep);
  word-break: break-word;
}

.idea-card .idea-add-btn {
  margin-top: 10px;
  padding: 6px 10px;
  background: var(--ink);
  color: var(--bg);
  border: none;
  border-radius: 4px;
  font-size: 12px;
}

.idea-card .idea-add-btn:hover { background: var(--accent); }
.idea-card .idea-add-btn.added { background: var(--good); }

/* ========== CALENDAR ========== */
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 10px;
}

.cal-day {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  min-height: 200px;
  display: flex;
  flex-direction: column;
}

.cal-day-head {
  font-family: var(--osd);
  font-size: 16px;
  color: var(--sepia);
  letter-spacing: 1px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 6px;
  margin-bottom: 8px;
}

.cal-day-time {
  font-family: var(--osd);
  font-size: 13px;
  color: var(--accent);
  margin-bottom: 8px;
}

.cal-item {
  background: var(--bg-soft);
  border-radius: 4px;
  padding: 6px 8px;
  font-size: 12px;
  margin-bottom: 6px;
  line-height: 1.3;
}

.cal-item-title { font-weight: 600; color: var(--ink); }
.cal-item-tag { font-size: 11px; color: var(--ink-soft); margin-top: 2px; }

/* ========== MODAL ========== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(43, 36, 25, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}

.modal-backdrop[hidden] { display: none; }

.modal {
  background: var(--bg);
  border: 2px solid var(--ink);
  border-radius: 10px;
  padding: 28px;
  max-width: 460px;
  width: 100%;
  box-shadow: 0 8px 24px rgba(0,0,0,0.3);
}

.modal h2 {
  margin: 0 0 12px;
  font-size: 20px;
}

.modal p {
  font-size: 13.5px;
  margin: 0 0 14px;
  color: var(--ink-soft);
}

.guide-list {
  font-size: 13px;
  margin: 0 0 14px;
  padding-left: 20px;
  color: var(--ink-soft);
}

.guide-list li { margin-bottom: 4px; }

.guide-list a {
  color: var(--accent);
  text-decoration: underline;
}

#api-key-input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border-dark);
  border-radius: 6px;
  font-family: 'Courier New', monospace;
  font-size: 13px;
  margin-bottom: 14px;
  background: var(--bg-card);
}

.modal-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.modal-foot {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  font-size: 11.5px;
  color: var(--sepia);
  line-height: 1.5;
}

/* ========== LOADING ========== */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(43, 36, 25, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
}

.loading-overlay[hidden] { display: none; }

.loading-box {
  background: var(--ink);
  color: var(--bg);
  padding: 20px 32px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  gap: 12px;
  font-family: var(--osd);
  font-size: 18px;
  letter-spacing: 1px;
}

.loading-dot { width: 14px; height: 14px; }

/* ========== HOOK RESULT ========== */
.hook-output { display: grid; gap: 10px; }
.hook-output .hook-line {
  background: var(--bg-soft);
  border-left: 3px solid var(--accent);
  padding: 8px 12px;
  font-size: 14px;
}

/* ========== RESPONSIVE ========== */
@media (max-width: 900px) {
  .main-wrap { grid-template-columns: 1fr; }
  .sidebar {
    border-right: none;
    border-bottom: 2px solid var(--border-dark);
  }
  .sidebar nav { flex-direction: row; flex-wrap: wrap; }
  .tab-btn { flex: 1; min-width: 130px; }
  .content { padding: 20px; }
  .calendar-grid { grid-template-columns: 1fr 1fr; }
}
