/*
 * Taste UI layer for the dashboard.
 * The original stylesheet remains underneath this file as a compatibility layer.
 */

:root {
  --bg: #f3f6fa;
  --surface: rgba(255, 255, 255, .99);
  --surface-solid: #ffffff;
  --surface-muted: #f7f9fc;
  --surface-purple: #edf4ff;
  --border: #dfe5ee;
  --border-strong: #c8d1de;
  --text: #1b2534;
  --heading: #121b2a;
  --muted: #5e6b7c;
  --muted-soft: #8995a5;
  --primary: #175cd3;
  --primary-hover: #144ba7;
  --primary-light: #eaf2ff;
  --primary-border: #b9d2f4;
  --accent: #175cd3;
  --success: #067647;
  --warning: #b54708;
  --danger: #b42318;
  --radius-sm: 9px;
  --radius: 13px;
  --radius-lg: 16px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 8px 24px rgba(38, 51, 77, .045);
  --shadow-floating: 0 20px 56px rgba(18, 27, 42, .16);
  --content-width: 1340px;
  --page-gutter: clamp(18px, 2.7vw, 38px);
  --sidebar-width: 256px;
}

html,
body {
  background: var(--bg);
}

body {
  background-image: none;
  background-attachment: scroll;
  font-family: "Segoe UI Variable", "Segoe UI", Roboto, Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
}

#dashboardApp {
  min-height: 100dvh;
  padding-left: var(--sidebar-width);
}

input,
textarea,
select {
  border-color: var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-solid);
  box-shadow: none;
}

input,
select {
  min-height: 44px;
  padding: 9px 12px;
}

textarea {
  padding: 11px 12px;
}

input:hover,
textarea:hover,
select:hover {
  border-color: #9daabc;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(23, 92, 211, .14);
}

button:focus-visible,
.record-link-list:focus-visible,
.record-link-view:focus-visible {
  outline: 3px solid rgba(23, 92, 211, .24);
  outline-offset: 2px;
}

button:active:not(:disabled) {
  transform: scale(.985);
}

::selection {
  color: #ffffff;
  background: var(--primary);
}

h1,
h2,
h3 {
  color: var(--heading);
  letter-spacing: -.018em;
}

/* License gate */
.license-gate {
  padding: clamp(18px, 4vw, 48px);
  background: var(--bg);
}

.license-card {
  width: min(680px, 100%);
  padding: clamp(28px, 5vw, 46px);
  border-color: var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface-solid);
  box-shadow: var(--shadow-floating);
  text-align: left;
}

.license-mark {
  width: 58px;
  height: 58px;
  margin: 0 0 22px;
  color: #ffffff;
  border-radius: 12px;
  background: var(--primary);
  box-shadow: none;
  font-size: 13px;
  letter-spacing: .08em;
}

.license-card h1 {
  max-width: 560px;
  margin-bottom: 10px;
  font-size: clamp(26px, 3.6vw, 35px);
}

.license-card label {
  margin-top: 26px;
  color: var(--text);
  font-size: 12px;
  letter-spacing: .03em;
}

.license-instruction {
  color: var(--muted);
  font-size: 15px;
}

.license-key-row input {
  min-height: 52px;
  color: #144ba7;
  border-color: var(--primary-border);
  background: #f4f8ff;
  font-size: 14px;
}

/* Fixed app shell */
.app-header {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 30;
  width: var(--sidebar-width);
  height: 100dvh;
  border: 0;
  border-right: 1px solid var(--border);
  background: var(--surface-solid);
  box-shadow: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

.header-inner {
  width: 100%;
  height: 100%;
  min-height: 0;
  margin: 0;
  padding: 20px 14px 16px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  gap: 20px;
}

.app-brand {
  width: 100%;
  padding: 0 8px 18px;
  display: flex;
  align-items: center;
  gap: 11px;
  border-bottom: 1px solid var(--border);
}

.brand-logo {
  width: 40px;
  height: 40px;
  border: 1px solid #cfe0f8;
  border-radius: 10px;
  background: #edf4ff;
  box-shadow: none;
}

.brand-logo-image {
  width: 30px;
  height: 30px;
  border-radius: 8px;
}

.brand-copy {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.brand-title {
  overflow: hidden;
  color: var(--heading);
  font-size: 14px;
  font-weight: 750;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.brand-subtitle {
  overflow: hidden;
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.header-nav {
  width: 100%;
  min-height: 0;
  padding: 0 2px;
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  gap: 3px;
  overflow-x: hidden;
  overflow-y: auto;
  scrollbar-width: thin;
}

.nav-section-label {
  padding: 0 10px 6px;
  color: #7b8797;
  font-size: 10px;
  font-weight: 750;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.nav-section-workspace {
  margin-top: 18px;
}

.nav-button {
  position: relative;
  width: 100%;
  min-height: 42px;
  padding: 9px 12px;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  color: #455266;
  border: 0;
  border-radius: 8px;
  background: transparent;
  box-shadow: none;
  font-size: 13px;
  font-weight: 650;
  text-align: left;
  transition: color .16s ease, background-color .16s ease, transform .16s ease;
}

.nav-button:hover,
.nav-button.is-active {
  color: #144ba7;
  border-color: transparent;
  background: #edf4ff;
  box-shadow: none;
  transform: none;
}

.nav-button.is-active::before {
  content: "";
  position: absolute;
  top: 9px;
  bottom: 9px;
  left: 0;
  width: 3px;
  border-radius: 3px;
  background: var(--primary);
}

.sidebar-meta {
  margin-top: auto;
  padding: 13px 10px 4px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--muted);
  border-top: 1px solid var(--border);
  font-size: 11px;
}

.sidebar-meta strong {
  color: var(--heading);
  font-family: Consolas, "Courier New", monospace;
  font-size: 11px;
}

/* Content frame */
.app-main,
.dashboard-page {
  width: min(var(--content-width), calc(100% - (var(--page-gutter) * 2)));
  margin: 0 auto;
  padding: clamp(24px, 3vw, 38px) 0 clamp(42px, 5vw, 68px);
}

.dashboard-page.show {
  animation: taste-page-in .18s cubic-bezier(.16, 1, .3, 1);
}

.page-card,
.wide-page,
.settings-page,
.prompt-editor-page {
  width: 100%;
}

.page-heading {
  position: sticky;
  top: 0;
  z-index: 8;
  min-height: 70px;
  margin: -12px 0 14px;
  padding: 12px 0 14px;
  border-bottom: 1px solid rgba(223, 229, 238, .92);
  background: rgba(243, 246, 250, .94);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.page-heading h2 {
  font-size: clamp(21px, 1.8vw, 26px);
}

.page-heading p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

#apiSettingsModal .page-content,
#templateModal .page-content {
  padding: clamp(18px, 2vw, 25px);
  border-color: var(--border);
  border-radius: var(--radius);
  background: var(--surface-solid);
  box-shadow: var(--shadow);
}

/* Home status */
.status-card {
  padding: 0;
  grid-template-columns: minmax(0, 1.08fr) minmax(360px, .92fr);
  gap: 18px;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.status-overview {
  padding: clamp(20px, 2.3vw, 28px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-solid);
  box-shadow: var(--shadow);
}

.status-title-group {
  gap: 12px;
}

.status-icon {
  width: 46px;
  height: 46px;
  color: #144ba7;
  border: 1px solid var(--primary-border);
  border-radius: 10px;
  background: var(--primary-light);
  box-shadow: none;
  font-family: Consolas, "Courier New", monospace;
  font-size: 9px;
  font-weight: 900;
  letter-spacing: .06em;
}

.eyebrow {
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 650;
  letter-spacing: 0;
  text-transform: none;
}

.status-heading h1 {
  font-size: clamp(23px, 2.2vw, 30px);
}

.terminal-state-badge {
  padding: 7px 10px;
  border-radius: 8px;
  font-size: 11px;
  letter-spacing: .025em;
}

.current-process {
  margin-top: 22px;
  padding: 15px 16px;
  border-color: #cfe0f8;
  border-left: 4px solid var(--primary);
  border-radius: 10px;
  background: #f4f8ff;
}

.current-process strong {
  color: var(--heading);
  font-size: 16px;
}

.process-meta,
.status-counts {
  gap: 1px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--border);
}

.process-meta span,
.status-counts span,
.status-counts span:first-child,
.status-counts span:nth-child(2),
.status-counts span:nth-child(3) {
  padding: 10px 11px;
  border: 0;
  border-radius: 0;
  background: var(--surface-solid);
}

.status-counts span:first-child strong {
  color: var(--success);
}

.status-counts span:nth-child(2) strong {
  color: var(--warning);
}

.status-counts span:nth-child(3) strong {
  color: var(--danger);
}

.process-target {
  border-color: var(--border);
  border-radius: 10px;
  background: var(--surface-muted);
}

.process-target span {
  letter-spacing: .025em;
}

.process-countdown {
  border-color: var(--border);
  border-radius: 10px;
  background: var(--surface-muted);
}

.progress-track {
  height: 8px;
  border-radius: 8px;
  background: #dce4ef;
  box-shadow: none;
}

.progress-track i {
  border-radius: inherit;
  background: var(--primary);
  box-shadow: none;
}

.status-console {
  padding: clamp(20px, 2.3vw, 28px);
  border-color: #233044;
  border-radius: var(--radius);
  background: #141d2b;
  box-shadow: 0 12px 32px rgba(18, 27, 42, .12);
}

.status-console-heading {
  color: #edf2f8;
}

.live-indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #34c789;
  box-shadow: none;
}

.status-console-heading > span {
  color: #9fbff0;
  font-size: 10px;
  letter-spacing: .1em;
}

.terminal-log {
  min-height: 286px;
  color: #dbe5f2;
  border-color: #29374d;
  border-radius: 10px;
  background: #0f1723;
}

.terminal-line.is-running b {
  color: #91b7ee;
}

/* Actions */
.primary-button,
.danger-button,
.secondary-button,
.btn {
  border-radius: 8px;
  box-shadow: none;
  font-weight: 700;
  transition: color .16s ease, border-color .16s ease, background-color .16s ease, transform .16s ease;
}

.primary-button {
  color: #ffffff;
  border-color: var(--primary);
  background: var(--primary);
}

.primary-button:hover {
  border-color: var(--primary-hover);
  background: var(--primary-hover);
  box-shadow: none;
  transform: translateY(-1px);
}

.secondary-button {
  color: #334155;
  border-color: var(--border-strong);
  background: var(--surface-solid);
  box-shadow: none;
}

.secondary-button:hover {
  color: #144ba7;
  border-color: var(--primary-border);
  background: var(--primary-light);
  box-shadow: none;
  transform: translateY(-1px);
}

.danger-button {
  color: #ffffff;
  border-color: var(--danger);
  background: var(--danger);
  box-shadow: none;
}

.danger-button:hover {
  background: #912018;
  box-shadow: none;
}

.status-console .secondary-button {
  color: #dce7f5;
  border-color: #40506a;
  background: #1b2738;
}

.status-console .secondary-button:hover {
  color: #ffffff;
  border-color: #5e7596;
  background: #223249;
}

.auto-run-actions {
  gap: 9px;
}

.auto-run-button,
.auto-stop-button {
  min-height: 46px;
}

.small-button {
  min-height: 35px;
}

.secret-toggle {
  min-width: 58px;
}

/* Panels and forms */
.panel {
  padding: clamp(17px, 1.7vw, 22px);
  border-color: var(--border);
  border-radius: var(--radius);
  background: var(--surface-solid);
  box-shadow: var(--shadow);
}

.panel + .panel {
  margin-top: 16px;
}

.panel-toolbar {
  min-height: 38px;
  margin-bottom: 14px;
}

.counter-badge {
  padding: 5px 9px;
  color: #144ba7;
  border-color: var(--primary-border);
  border-radius: 8px;
  background: var(--primary-light);
  font-size: 12px;
}

.form-group label {
  color: #2f3b4d;
  font-size: 13px;
  font-weight: 700;
}

.hint,
.counter,
.link-preview {
  color: var(--muted);
}

.output-panel #output {
  border-color: var(--border);
  border-radius: 10px;
  background: var(--surface-muted);
}

.composer-tabs {
  width: 100%;
  padding: 0;
  display: flex;
  gap: 0;
  border: 0;
  border-bottom: 1px solid var(--border);
  border-radius: 0;
  background: transparent;
}

.composer-tab {
  min-height: 43px;
  padding: 9px 16px;
  color: var(--muted);
  border: 0;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.composer-tab:hover,
.composer-tab.is-active {
  color: #144ba7;
  border-color: var(--primary);
  background: transparent;
  box-shadow: none;
}

.manual-random-format,
.manual-auto-comment-note {
  border-radius: 10px;
}

.manual-random-format {
  background: #f7f9fc;
}

.manual-auto-comment-note {
  border-color: #cfe0f8;
  background: #f4f8ff;
}

.manual-random-format code {
  color: #144ba7;
  border-color: #cfe0f8;
}

.records-grid {
  gap: 16px;
}

.record-success,
.record-removed,
.record-error {
  border-top: 1px solid var(--border);
}

.record-success {
  border-left: 4px solid var(--success);
}

.record-removed {
  border-left: 4px solid var(--warning);
}

.record-error {
  border-left: 4px solid var(--danger);
}

.record-link-list {
  border-color: var(--border);
  border-radius: 9px;
}

.record-summary span {
  border-color: var(--border);
  border-radius: 9px;
  background: var(--surface-solid);
}

.tpl-empty {
  border-color: var(--border-strong);
  border-radius: 10px;
  background: var(--surface-muted);
}

.tpl-item {
  border-color: var(--border);
  border-radius: 10px;
  background: var(--surface-solid);
  box-shadow: none;
}

.tpl-item:hover,
.tpl-item.active {
  border-color: var(--primary-border);
  background: #f8fbff;
  box-shadow: none;
}

.tpl-icon {
  color: #144ba7;
  border: 1px solid var(--primary-border);
  border-radius: 9px;
  background: var(--primary-light);
  font-size: 0;
}

.tpl-icon::after {
  content: "M";
  font-family: Consolas, "Courier New", monospace;
  font-size: 13px;
  font-weight: 900;
}

.btn {
  min-height: 34px;
  padding: 6px 10px;
  cursor: pointer;
  font-size: 12px;
}

.btn-soft {
  color: #144ba7;
  border: 1px solid var(--primary-border);
  background: var(--primary-light);
}

.btn-danger {
  color: var(--danger);
  border: 1px solid #efc3bf;
  background: #fff4f3;
}

.btn:hover {
  transform: translateY(-1px);
}

/* Settings */
.setting-switch {
  border-color: #cfe0f8;
  border-radius: 10px;
  background: #f4f8ff;
}

.setting-switch:hover {
  border-color: #9eb9de;
  background: #edf4ff;
}

.setting-switch-track {
  border-color: #aeb8c6;
  background: #cbd3df;
  box-shadow: none;
}

.setting-switch-control input:checked + .setting-switch-track {
  border-color: var(--primary);
  background: var(--primary);
}

.setting-switch-control input:focus-visible + .setting-switch-track {
  box-shadow: 0 0 0 3px rgba(23, 92, 211, .18);
}

.auth-bar {
  border-color: #cfe0f8;
  border-radius: 10px;
  background: #f4f8ff;
}

.auth-bar > span {
  color: #144ba7;
  border: 1px solid var(--primary-border);
  border-radius: 8px;
  background: #ffffff;
}

.notice {
  border-radius: 9px;
}

.prompt-editor-notice {
  color: #144ba7;
  border-color: var(--primary-border);
  border-radius: 9px;
  background: var(--primary-light);
}

.prompt-editor-card code {
  color: #144ba7;
}

.prompt-editor-actions {
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: rgba(255, 255, 255, .96);
  box-shadow: var(--shadow);
}

.toast {
  border-radius: 9px;
  box-shadow: var(--shadow-floating);
}

@keyframes taste-page-in {
  from { opacity: 0; transform: translateY(5px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 1250px) {
  .status-card {
    grid-template-columns: 1fr;
  }

  .status-console {
    min-height: 370px;
  }

  .records-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .record-summary {
    grid-column: 1 / -1;
  }
}

@media (max-width: 980px) {
  :root {
    --page-gutter: 16px;
  }

  #dashboardApp {
    padding-left: 0;
  }

  .app-header {
    position: sticky;
    inset: 0 auto auto 0;
    width: 100%;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

  .header-inner {
    width: 100%;
    height: auto;
    min-height: 0;
    padding: 9px 14px 10px;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
  }

  .app-brand {
    width: auto;
    padding: 0;
    border: 0;
  }

  .brand-logo {
    width: 38px;
    height: 38px;
  }

  .brand-logo-image {
    width: 28px;
    height: 28px;
  }

  .sidebar-meta,
  .nav-section-label {
    display: none;
  }

  .header-nav {
    order: 2;
    width: 100%;
    padding: 3px 0 0;
    display: flex;
    flex-direction: row;
    gap: 4px;
    overflow-x: auto;
    overflow-y: hidden;
  }

  .nav-button {
    width: auto;
    min-height: 37px;
    padding: 7px 11px;
    white-space: nowrap;
  }

  .nav-button.is-active::before {
    inset: auto 10px 0;
    width: auto;
    height: 2px;
  }

  .app-main,
  .dashboard-page {
    width: calc(100% - 30px);
    padding-top: 22px;
  }

  .page-heading {
    position: static;
    margin-top: 0;
    background: transparent;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }

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

  .record-summary {
    grid-column: auto;
  }
}

@media (max-width: 760px) {
  .two-column,
  .input-grid,
  .settings-grid {
    grid-template-columns: 1fr;
  }

  .settings-wide,
  .daily-comment-limit-setting {
    grid-column: auto;
  }

  .process-meta,
  .status-counts {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .header-inner {
    padding-inline: 12px;
  }

  .brand-subtitle {
    display: none;
  }

  .app-main,
  .dashboard-page {
    width: calc(100% - 24px);
    padding-top: 18px;
  }

  .status-overview,
  .status-console,
  .panel,
  #apiSettingsModal .page-content,
  #templateModal .page-content {
    padding: 15px;
  }

  .status-card {
    gap: 13px;
  }

  .auto-run-actions,
  .prompt-editor-actions {
    flex-direction: column;
  }

  .prompt-editor-actions {
    padding: 10px;
  }
}

@media (max-width: 430px) {
  .brand-title {
    font-size: 13px;
  }

  .status-heading {
    flex-direction: column;
  }

  .process-meta,
  .status-counts {
    grid-template-columns: 1fr;
  }

  .license-card {
    padding: 26px 17px;
  }

  .license-key-row {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: .01ms !important;
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
  }
}
