/* ─── Application Window ─────────────────────── */
.excel-window {
  width: min(960px, 100%);
  height: calc(100vh - 40px);
  background: var(--chrome-bg);
  border: 1px solid #888;
  box-shadow:
    0 4px 20px rgba(0,0,0,0.45),
    0 1px 3px rgba(0,0,0,0.3),
    inset 0 1px 0 rgba(255,255,255,0.6);
  display: flex;
  flex-direction: column;
  user-select: none;
}

/* ─── Title Bar ──────────────────────────────── */
.title-bar {
  height: 30px;
  background: linear-gradient(180deg, #fefefe 0%, #f0f0f0 100%);
  border-bottom: 1px solid var(--chrome-border);
  display: flex;
  align-items: center;
  padding: 0 8px;
  gap: 6px;
}
.title-bar-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}
.title-bar-text {
  flex: 1;
  text-align: center;
  font-family: var(--font-ui);
  font-size: 12px;
  color: var(--chrome-text);
  letter-spacing: 0.01em;
}
.window-controls {
  display: flex;
  gap: 2px;
  margin-left: auto;
}
.wc-btn {
  width: 26px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: default;
  font-size: 10px;
  color: #555;
  border: 1px solid transparent;
}
.wc-btn:hover { background: var(--chrome-hover); border-color: var(--chrome-border); }
.wc-btn.close:hover { background: #c42b1c; color: #fff; border-color: #c42b1c; }
.wc-btn svg { width: 10px; height: 10px; }

/* ─── Menu Bar ───────────────────────────────── */
.menu-bar {
  height: 24px;
  background: var(--chrome-bg);
  border-bottom: 1px solid var(--chrome-border);
  display: flex;
  align-items: stretch;
  padding: 0 4px;
}
.menu-item {
  padding: 0 8px;
  display: flex;
  align-items: center;
  font-family: var(--font-ui);
  font-size: 12px;
  color: var(--chrome-text);
  cursor: default;
  position: relative;
}
.menu-item:hover {
  background: var(--chrome-hover);
}
.menu-item span { text-decoration-line: none; }
.menu-item u { text-decoration: underline; }

/* ─── Ribbon Tabs ────────────────────────────── */
.ribbon-tabs {
  height: 26px;
  background: var(--ribbon-bg);
  display: flex;
  align-items: flex-end;
  padding: 0 8px;
}
.ribbon-tab {
  padding: 0 14px;
  height: 22px;
  display: flex;
  align-items: center;
  font-family: var(--font-ui);
  font-size: 11.5px;
  color: rgba(255,255,255,0.85);
  cursor: default;
  border-radius: 3px 3px 0 0;
}
.ribbon-tab:hover { color: #fff; background: rgba(255,255,255,0.12); }
.ribbon-tab.active {
  background: var(--ribbon-tab-active);
  color: var(--ribbon-bg);
  font-weight: 600;
}

/* ─── Toolbar ────────────────────────────────── */
.toolbar {
  height: 36px;
  background: var(--toolbar-bg);
  border-bottom: 1px solid var(--toolbar-border);
  display: flex;
  align-items: center;
  padding: 0 6px;
  gap: 2px;
}
.tb-btn {
  width: 28px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  border-radius: 2px;
  cursor: default;
  color: #555;
}
.tb-btn:hover { background: var(--chrome-hover); border-color: var(--chrome-border); }
.tb-btn svg { width: 15px; height: 15px; }
.tb-sep {
  width: 1px;
  height: 20px;
  background: var(--chrome-border);
  margin: 0 3px;
}
.tb-font-select {
  height: 22px;
  width: 120px;
  border: 1px solid var(--chrome-border);
  border-radius: 2px;
  background: #fff;
  font-family: var(--font-ui);
  font-size: 11.5px;
  padding: 0 4px;
  color: var(--chrome-text);
  appearance: none;
}
.tb-font-size {
  width: 40px;
  height: 22px;
  border: 1px solid var(--chrome-border);
  border-radius: 2px;
  background: #fff;
  font-family: var(--font-ui);
  font-size: 11.5px;
  padding: 0 4px;
  text-align: center;
  color: var(--chrome-text);
}

/* ─── Formula Bar ────────────────────────────── */
.formula-bar {
  height: 28px;
  background: var(--formula-bg);
  border-bottom: 1px solid var(--formula-border);
  display: flex;
  align-items: center;
  gap: 0;
}
.name-box {
  width: 82px;
  height: 100%;
  border-right: 1px solid var(--formula-border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-chrome);
  font-size: 12px;
  color: var(--chrome-text);
  padding: 0 6px;
  flex-shrink: 0;
}
.formula-icons {
  display: flex;
  align-items: center;
  height: 100%;
  border-right: 1px solid var(--formula-border);
}
.fi-btn {
  width: 26px;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: #666;
  font-size: 13px;
}
.fi-btn:hover { background: var(--chrome-hover); }
.fi-btn.confirm { color: #217346; font-weight: bold; }
.fi-btn.cancel { color: #c0392b; }
.fi-fx {
  width: 28px;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-chrome);
  font-size: 12px;
  color: #555;
  border-right: 1px solid var(--formula-border);
  font-style: italic;
}
.formula-input-wrap {
  flex: 1;
  height: 100%;
  position: relative;
}
/* Riley: visible focus ring on formula bar wrapper */
.formula-input-wrap:focus-within {
  outline: 2px solid var(--cell-selected-border);
  outline-offset: -2px;
}
#formula-input {
  width: 100%;
  height: 100%;
  border: none;
  outline: none;
  padding: 0 8px;
  font-family: var(--font-chrome);
  font-size: 13px;
  color: var(--chrome-text);
  background: transparent;
  caret-color: #1973c4;
}
#formula-input::placeholder {
  color: #bbb;
  font-style: italic;
}

/* formula-input + confirm button during analysis */
.formula-input-wrap.analyzing input {
  opacity: 0.55;
  pointer-events: none;
}
#btn-confirm.analyzing {
  opacity: 0.4;
  pointer-events: none;
  cursor: default;
}

/* ─── Sheet Tabs ─────────────────────────────── */
.sheet-tabs {
  height: 26px;
  background: var(--chrome-bg);
  border-top: 1px solid var(--chrome-border);
  display: flex;
  align-items: flex-end;
  padding: 0 8px;
  gap: 2px;
}
.sheet-tab {
  height: 22px;
  padding: 0 14px;
  display: flex;
  align-items: center;
  font-family: var(--font-ui);
  font-size: 11.5px;
  border: 1px solid var(--chrome-border);
  border-bottom: none;
  border-radius: 3px 3px 0 0;
  cursor: pointer;
  color: #777;
  background: #e8e8e8;
  outline: none;
}
.sheet-tab:hover:not(.active) { background: #d8d8d8; color: #444; }
.sheet-tab:focus-visible {
  outline: 2px solid var(--ribbon-bg);
  outline-offset: -2px;
}
.sheet-tab.active {
  background: #fff;
  color: var(--chrome-text);
  border-bottom: 1px solid #fff;
  margin-bottom: -1px;
  font-weight: 500;
  cursor: default;
}

/* ─── Status Bar ─────────────────────────────── */
.status-bar {
  height: 22px;
  background: var(--ribbon-bg);
  border-top: 1px solid #1a5e38;
  display: flex;
  align-items: center;
  padding: 0 10px;
  gap: 16px;
}
.status-item {
  font-family: var(--font-ui);
  font-size: 11px;
  color: rgba(255,255,255,0.85);
  letter-spacing: 0.02em;
}
.status-item.ready { font-weight: 500; }
.status-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 4px;
}
.zoom-control {
  display: flex;
  align-items: center;
  gap: 4px;
}
.zoom-track {
  width: 80px;
  height: 4px;
  background: rgba(255,255,255,0.25);
  border-radius: 2px;
  position: relative;
}
/* Riley: zoom updated to 100% */
.zoom-fill {
  width: 100%;
  height: 100%;
  background: rgba(255,255,255,0.7);
  border-radius: 2px;
}
.zoom-thumb {
  position: absolute;
  top: -4px;
  left: 100%;
  transform: translateX(-50%);
  width: 10px;
  height: 10px;
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

/* ─── Mobile Layout (≤767px) ─────────────────── */
@media (max-width: 767px) {
  .excel-window {
    width: 100%;
    height: 100vh;
    border: none;
    box-shadow: none;
  }
  .menu-bar,
  .ribbon-tabs,
  .toolbar,
  .title-bar-text,
  .window-controls { display: none; }

  .formula-bar {
    height: 52px;
    flex-wrap: nowrap;
    position: relative;
  }
  .name-box { display: none; }
  .formula-icons { border-right: none; order: 2; }
  .fi-btn.cancel { display: none; }
  .fi-btn.confirm {
    width: 52px;
    height: 52px;
    font-size: 0;
    order: 2;
    background: var(--ribbon-bg);
    color: #fff;
    border-radius: 0;
    font-family: var(--font-ui);
    font-weight: 700;
  }
  .fi-btn.confirm::after {
    content: '전송';
    font-size: 12px;
  }
  .fi-fx { display: none; }
  .formula-input-wrap { order: 1; flex: 1; }

  .sheet-tabs { height: 40px; }
}

/* ─── User Info (title bar) ──────────────────── */
.user-info {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: 12px;
}
.user-info.hidden { display: none; }
.user-name {
  font-family: var(--font-ui);
  font-size: 11px;
  color: #555;
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.signout-btn {
  font-family: var(--font-ui);
  font-size: 11px;
  color: #666;
  background: none;
  border: 1px solid #ccc;
  border-radius: 3px;
  padding: 2px 8px;
  cursor: pointer;
}
.signout-btn:hover { background: var(--chrome-hover); }
