@tailwind base;
@tailwind components;
@tailwind utilities;

:root {
  color: #111827;
  background: #eef1f5;
  font-family: "PingFang SC", "Helvetica Neue", Arial, sans-serif;
  line-height: 1.4;
}

html,
body,
#app {
  min-height: 100%;
}

body {
  margin: 0;
}

* {
  box-sizing: border-box;
}

button,
input,
select,
textarea {
  font: inherit;
}

.app-shell {
  width: 100%;
  max-width: 1680px;
  margin: 0 auto;
  padding: 14px;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.panel {
  background: linear-gradient(180deg, #ffffff 0%, #fbfcfe 100%);
  border: 1px solid #d9e0e8;
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.05);
}

.topbar {
  padding: 14px 16px;
  flex: 0 0 auto;
}

.toolbar-main,
.toolbar-actions,
.workspace-header,
.task-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-width: 0;
}

.toolbar-title,
.panel-title {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.toolbar-title strong,
.panel-title strong,
.workspace-header strong {
  font-size: 15px;
  font-weight: 600;
  color: #0f172a;
}

.toolbar-title span,
.panel-subtitle,
.subtle,
.feedback,
.empty-state {
  color: #64748b;
  font-size: 12px;
}

.credit-line {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: center;
}

.credit-line a {
  color: #0f172a;
  text-decoration: none;
}

.credit-line a:hover {
  text-decoration: underline;
}

.workspace-toolbar,
.advanced-shell {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid #e6ebf1;
}

.group-title {
  display: inline-block;
  margin-bottom: 8px;
  color: #475569;
  font-size: 12px;
  font-weight: 600;
}

.form-grid,
.advanced-grid {
  display: grid;
  gap: 10px;
}

.form-grid {
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  align-items: end;
}

.advanced-grid {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.field,
.check {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 12px;
}

.field span {
  color: #475569;
}

.field input,
.field select,
.editor-input,
.button,
.task-item,
.segment-item {
  min-width: 0;
}

.field input,
.field select,
.editor-input {
  width: 100%;
  min-height: 34px;
  padding: 6px 9px;
  border: 1px solid #cfd8e3;
  border-radius: 8px;
  background: #fff;
  color: #0f172a;
}

.field input:focus,
.field select:focus,
.editor-input:focus {
  outline: none;
  border-color: #94a3b8;
  box-shadow: 0 0 0 3px rgba(148, 163, 184, 0.16);
}

.check {
  flex-direction: row;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  padding: 0 10px;
  border: 1px solid #d9e0e8;
  border-radius: 8px;
  background: #f8fafc;
}

.check input {
  margin: 0;
}

.desktop-check {
  justify-content: flex-start;
}

.wide {
  grid-column: span 2;
}

.button {
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid #1f2937;
  border-radius: 8px;
  background: #1f2937;
  color: #fff;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.button:hover {
  background: #111827;
}

.button.secondary {
  background: #fff;
  color: #111827;
  border-color: #cfd8e3;
}

.button.secondary:hover {
  background: #f8fafc;
}

.button.small {
  min-height: 30px;
  padding: 0 10px;
  font-size: 12px;
}

.button:disabled {
  cursor: default;
  opacity: 0.6;
}

.status-text {
  min-height: 18px;
  margin: 10px 0 0;
}

.content-grid {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  gap: 14px;
  min-height: 0;
  flex: 1 1 auto;
}

.sidebar-panel,
.workspace-panel {
  min-height: 0;
}

.sidebar-panel {
  display: flex;
  flex-direction: column;
  padding: 12px;
}

.workspace-panel {
  display: flex;
  flex-direction: column;
  padding: 14px;
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 26px;
  height: 26px;
  padding: 0 8px;
  border-radius: 999px;
  background: #e2e8f0;
  color: #334155;
  font-size: 12px;
  font-weight: 600;
}

.empty-state {
  padding: 14px 0;
}

.list-stack,
.segment-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.list-stack {
  min-height: 0;
  overflow: auto;
}

.segment-list {
  min-height: 0;
  flex: 1 1 auto;
  overflow: auto;
  padding-right: 2px;
}

.task-item,
.segment-item {
  width: 100%;
  padding: 10px;
  border: 1px solid #e3e8ef;
  border-radius: 10px;
  background: #f8fafc;
  text-align: left;
}

.task-item.active {
  border-color: #94a3b8;
  background: #eef2f7;
}

.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.progress {
  height: 4px;
  margin-top: 6px;
  background: #dbe4ee;
  border-radius: 999px;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  background: #334155;
}

.error-text {
  margin: 6px 0 0;
  color: #b91c1c;
  font-size: 12px;
}

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

.source-text {
  margin: 8px 0;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 13px;
  color: #0f172a;
}

.editor-input {
  min-height: 64px;
  resize: vertical;
}

.log-drawer {
  margin-top: 12px;
  border-top: 1px solid #e6ebf1;
  padding-top: 12px;
}

.log-toggle {
  width: 100%;
  min-height: 38px;
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 10px;
  padding: 0 12px;
  border: 1px solid #d9e0e8;
  border-radius: 10px;
  background: #f8fafc;
  color: #0f172a;
  cursor: pointer;
}

.log-panel {
  margin-top: 10px;
}

.log-list {
  max-height: 220px;
  overflow: auto;
  padding: 10px;
  border: 1px solid #dfe6ee;
  border-radius: 10px;
  background: #0f172a;
}

.log-line {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 12px;
  line-height: 1.5;
  color: #dbe4ee;
}

.log-line + .log-line {
  margin-top: 4px;
}

@media (max-width: 1360px) {
  .content-grid {
    grid-template-columns: 300px minmax(0, 1fr);
  }

  .form-grid {
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  }

  .advanced-grid {
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  }

  .wide {
    grid-column: span 1;
  }
}
