/* ==========================================================================
   shell.css — global reset, color tokens, topbar/tabs, view container
   ========================================================================== */

* { box-sizing: border-box; }

:root {
  /* warm editorial palette — adopted from the news-article tool */
  --bg: #efe7dc;
  --bg2: #f7f3ed;
  --panel: #0f1827;
  --panel-soft: rgba(255, 255, 255, 0.06);
  --paper: rgba(255, 253, 250, 0.96);
  --line: rgba(112, 86, 57, 0.13);
  --ink: #181818;
  --muted: #645b52;
  --accent: #7b1f1f;
  --accent-soft: rgba(123, 31, 31, 0.08);
  --shadow: 0 24px 60px rgba(40, 26, 12, 0.12);

  --topbar-h: 96px;
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
               "Pretendard", "Apple SD Gothic Neo", sans-serif;
  -webkit-tap-highlight-color: transparent;
}

body {
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, #111a29 0%, #09111f 100%);
  color: var(--ink);
  overflow: hidden;
}

/* -------- topbar -------- */

.topbar {
  flex: 0 0 var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 0 22px;
  background: linear-gradient(180deg, #111a29 0%, #0c1422 100%);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  z-index: 5;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  color: rgba(255, 255, 255, 0.92);
}

.brand-mark {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
}

.brand-name {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: 1.8px;
  text-transform: uppercase;
}

.tabs {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 999px;
}

.tab {
  appearance: none;
  border: 0;
  background: transparent;
  color: rgba(255, 255, 255, 0.72);
  padding: 8px 16px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: 0.15s ease;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  line-height: 1;
}

.tab:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.06);
}

.tab:focus-visible {
  outline: 2px solid rgba(138, 180, 255, 0.7);
  outline-offset: 2px;
}

.tab.is-active {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 6px 18px rgba(123, 31, 31, 0.45);
}

.tab-icon {
  font-size: 15px;
  line-height: 1;
}

/* -------- tab group with submenu (hover dropdown on desktop) -------- */

.tab-group {
  position: relative;
  display: inline-flex;
}

.tab-parent {
  cursor: default;
}

.tab-parent .caret {
  font-size: 10px;
  opacity: 0.7;
  margin-left: 2px;
}

.tab-parent.has-active-child {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 6px 18px rgba(123, 31, 31, 0.45);
}

.submenu {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  flex-direction: column;
  gap: 2px;
  padding: 6px;
  min-width: 180px;
  background: linear-gradient(180deg, #111a29 0%, #0c1422 100%);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.45);
  z-index: 100;
}

/* .is-open is added by shell.js via hover-intent (mouseenter opens
   immediately; mouseleave schedules a short delayed close that gets
   cancelled if the mouse re-enters anywhere in .tab-group). This is
   robust against the gap between the parent and the submenu that pure
   :hover trips on. :focus-within preserves keyboard accessibility. */
.tab-group.is-open .submenu,
.tab-group:focus-within .submenu {
  display: flex;
}

.submenu .tab {
  width: 100%;
  justify-content: flex-start;
  border-radius: 8px;
}

.submenu-link {
  appearance: none;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  color: rgba(255, 255, 255, 0.72);
  font-size: 13px;
  font-weight: 700;
  font-family: inherit;
  line-height: 1;
  border-radius: 8px;
  transition: 0.15s ease;
  cursor: pointer;
}

.submenu-link:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.06);
}

.submenu-link:focus-visible {
  outline: 2px solid rgba(138, 180, 255, 0.7);
  outline-offset: 2px;
}

/* -------- shared per-card duplicate button (subtitle1 / ytcomment /
   igcomment / headline list items) — paired with each tool's
   .list-delete in the list-header. Global so each tool doesn't repeat
   the same rule. */

.list-duplicate {
  appearance: none;
  height: 26px;
  padding: 0 10px;
  border-radius: 999px;
  background: rgba(78, 163, 255, 0.14);
  color: #cce0ff;
  border: 1px solid rgba(78, 163, 255, 0.20);
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: 0.4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: 0.15s ease;
  flex-shrink: 0;
  font-family: inherit;
}

.list-duplicate:hover {
  background: rgba(78, 163, 255, 0.28);
  color: #ffffff;
  border-color: rgba(78, 163, 255, 0.45);
}

/* -------- view container -------- */

.view-container {
  flex: 1;
  min-height: 0;
  position: relative;
}

.view {
  position: absolute;
  inset: 0;
  /* layout per-view comes from article.css / headline.css */
}

.view[hidden] {
  display: none !important;
}

/* -------- shared scrollbar styling (dark-side panels) -------- */

.editor::-webkit-scrollbar,
.preview-wrap::-webkit-scrollbar,
.headline-sidebar::-webkit-scrollbar,
.subtitle1-sidebar::-webkit-scrollbar,
.ytcomment-sidebar::-webkit-scrollbar,
.circlecrop-sidebar::-webkit-scrollbar,
.multicrop-sidebar::-webkit-scrollbar,
.newsshow-sidebar::-webkit-scrollbar,
.canvas-wrap::-webkit-scrollbar,
.card-list::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

.editor::-webkit-scrollbar-thumb,
.preview-wrap::-webkit-scrollbar-thumb,
.headline-sidebar::-webkit-scrollbar-thumb,
.subtitle1-sidebar::-webkit-scrollbar-thumb,
.ytcomment-sidebar::-webkit-scrollbar-thumb,
.circlecrop-sidebar::-webkit-scrollbar-thumb,
.multicrop-sidebar::-webkit-scrollbar-thumb,
.newsshow-sidebar::-webkit-scrollbar-thumb,
.canvas-wrap::-webkit-scrollbar-thumb,
.card-list::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.18);
  border-radius: 999px;
}

/* -------- hamburger button (hidden on desktop) -------- */

.hamburger {
  display: none;
  appearance: none;
  border: 0;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 10px;
  padding: 10px;
  cursor: pointer;
  flex-direction: column;
  gap: 4px;
  flex-shrink: 0;
  transition: 0.15s ease;
}

.hamburger:hover {
  background: rgba(255, 255, 255, 0.12);
}

.hamburger-bar {
  display: block;
  width: 20px;
  height: 2px;
  background: rgba(255, 255, 255, 0.9);
  border-radius: 2px;
  transition: 0.25s ease;
  transform-origin: center;
}

/* X shape when menu is open */
.hamburger.is-open .hamburger-bar:nth-child(1) {
  transform: translateY(6px) rotate(45deg);
}
.hamburger.is-open .hamburger-bar:nth-child(2) {
  opacity: 0;
}
.hamburger.is-open .hamburger-bar:nth-child(3) {
  transform: translateY(-6px) rotate(-45deg);
}

/* mobile current-tab label (hidden on desktop) */
.mobile-tab-label {
  display: none;
  font-size: 14px;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.92);
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* backdrop behind dropdown (hidden on desktop) */
.menu-backdrop {
  display: none;
}

/* -------- topbar responsive (hamburger mode) -------- */

@media (max-width: 768px) {
  .topbar {
    position: relative;
    gap: 10px;
    padding: 0 14px;
    flex: 0 0 56px;
    --topbar-h: 56px;
  }

  .brand-mark {
    width: 40px;
    height: 40px;
  }

  .brand-name {
    display: none;
  }

  .hamburger {
    display: flex;
    order: 1;
  }

  .mobile-tab-label {
    display: block;
    text-align: center;
  }

  /* hide inline tabs — show as dropdown instead */
  .tabs {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    flex-direction: column;
    gap: 2px;
    padding: 8px 12px 12px;
    background: linear-gradient(180deg, #111a29 0%, #0c1422 100%);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 0 0 16px 16px;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.45);
    z-index: 100;
  }

  .tabs.is-open {
    display: flex;
  }

  .tab {
    padding: 12px 14px;
    border-radius: 12px;
    font-size: 14px;
    justify-content: flex-start;
    width: 100%;
  }

  .tab span:not(.tab-icon) {
    display: inline;
  }

  .tab.is-active {
    box-shadow: none;
  }

  /* tab-group accordion on mobile */
  .tab-group {
    width: 100%;
    flex-direction: column;
  }

  .tab-parent {
    width: 100%;
    justify-content: flex-start;
  }

  .tab-parent .caret {
    margin-left: auto;
    transition: transform 0.2s ease;
  }

  .tab-group.is-expanded .tab-parent .caret {
    transform: rotate(180deg);
  }

  /* disable desktop hover-intent open on mobile, only show when explicitly
     expanded via the accordion click */
  .tab-group.is-open .submenu,
  .tab-group:focus-within .submenu {
    display: none;
  }

  .submenu {
    position: static;
    transform: none;
    background: transparent;
    border: 0;
    box-shadow: none;
    padding: 4px 0 4px 16px;
    width: 100%;
    min-width: 0;
    gap: 2px;
  }

  .tab-group.is-expanded .submenu {
    display: flex;
  }

  .submenu-link {
    padding: 12px 14px;
    border-radius: 12px;
    font-size: 14px;
    width: 100%;
  }

  /* backdrop */
  .menu-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 4;
  }

  .menu-backdrop.is-open {
    display: block;
  }
}

/* -------- shared save/load button pair (.b2na files) ----------------------
   Used by every tool's sidebar bottom-bar. Styled here once with !important
   to win against tool-scoped `view-X button { ... }` defaults. -------- */

.persist-row {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.persist-row input[type="file"] {
  display: none;
}

.persist-btn {
  flex: 1 !important;
  background: rgba(255, 255, 255, 0.08) !important;
  color: #fff !important;
  border: 1px solid rgba(255, 255, 255, 0.14) !important;
  border-radius: 999px !important;
  padding: 8px 12px !important;
  font-size: 12px !important;
  font-weight: 700 !important;
  font-family: inherit !important;
  cursor: pointer !important;
  transition: 0.15s ease !important;
  box-shadow: none !important;
  appearance: none !important;
}

.persist-btn:hover {
  background: rgba(255, 255, 255, 0.14) !important;
  border-color: rgba(138, 180, 255, 0.7) !important;
}

/* -------- shared preset list (above save/load on every tool) ----------------
   Vertical list of horizontal cards: [thumb] [title] [불러오기]. Markup is
   added per-tab; a future preset-registry module can populate the list by id. */

.preset-section {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex-shrink: 0;
}

.preset-section-title {
  font-size: 11px;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.55);
  letter-spacing: 0.6px;
  text-transform: uppercase;
}

.preset-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 168px;
  overflow-y: auto;
  padding-right: 2px;
}

.preset-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  transition: 0.15s ease;
}

.preset-card:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.16);
}

.preset-thumb {
  width: 36px;
  height: 36px;
  border-radius: 6px;
  object-fit: cover;
  flex-shrink: 0;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.10), rgba(255, 255, 255, 0.02));
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  color: rgba(255, 255, 255, 0.55);
}

.preset-title {
  flex: 1;
  min-width: 0;
  font-size: 12px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.92);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.preset-load-btn {
  flex-shrink: 0 !important;
  background: rgba(255, 255, 255, 0.08) !important;
  color: #fff !important;
  border: 1px solid rgba(255, 255, 255, 0.14) !important;
  border-radius: 999px !important;
  padding: 5px 12px !important;
  font-size: 11px !important;
  font-weight: 700 !important;
  font-family: inherit !important;
  cursor: pointer !important;
  transition: 0.15s ease !important;
  box-shadow: none !important;
  appearance: none !important;
}

.preset-load-btn:hover {
  background: rgba(123, 31, 31, 0.7) !important;
  border-color: rgba(123, 31, 31, 0.85) !important;
}

.preset-list::-webkit-scrollbar { width: 8px; }
.preset-list::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.18);
  border-radius: 999px;
}

.preset-empty {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.4);
  text-align: center;
  padding: 12px 8px;
  font-style: italic;
}
