/* Base layout, notifications, legacy file tree and shared page utilities. */

* { box-sizing:border-box; }

body {
  margin:0;
  font-family:Inter, Segoe UI, Arial, sans-serif;
  background:var(--bg);
  color:var(--ink);
}

/* Not body: `font: inherit` there would replace the body font-family above with the browser's serif default. */
input,
select,
textarea,
button { font:inherit; }

a { color:inherit; }

.container {
  max-width:1160px;
  margin:28px auto;
  padding:0 20px;
}

.toast-host {
  position:fixed;
  top:18px;
  right:18px;
  z-index:var(--z-toast);
  display:flex;
  flex-direction:column;
  gap:10px;
  width:min(380px, calc(100vw - 36px));
  pointer-events:none;
}

.toast {
  pointer-events:auto;
  display:flex;
  align-items:flex-start;
  gap:10px;
  padding:14px 16px;
  border-radius:var(--radius);
  border:1px solid var(--line);
  background:var(--surface);
  color:var(--ink);
  box-shadow:0 16px 40px var(--alpha-shadow-16);
  animation:toast-in .28s ease-out;
  transition:opacity .2s ease, transform .2s ease;
}

.toast.is-leaving {
  opacity:0;
  transform:translateX(12px);
}

.toast__icon {
  flex-shrink:0;
  width:22px;
  height:22px;
  border-radius:var(--radius-round);
  display:grid;
  place-items:center;
  font-size:var(--text-12);
  font-weight:800;
  margin-top:1px;
}

.toast__body {
  flex:1;
  min-width:0;
  font-size:var(--text-14);
  line-height:1.45;
}

.toast--success {
  border-color:var(--color-green-50);
  background:var(--color-green-50);
}

.toast--success .toast__icon {
  background:var(--color-green-150);
  color:var(--color-neutral-50);
}

.toast--error {
  border-color:var(--color-red-150);
  background:var(--color-red-50);
}

.toast--error .toast__icon {
  background:var(--danger);
  color:var(--color-neutral-50);
}

.toast--warning {
  border-color:var(--color-earth-550);
  background:var(--color-earth-150);
}

.toast--warning .toast__icon {
  background:var(--color-earth-850);
  color:var(--color-neutral-50);
}

.toast--info {
  border-color:var(--color-blue-150);
  background:var(--color-blue-50);
}

.toast--info .toast__icon {
  background:var(--primary);
  color:var(--color-neutral-50);
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateX(16px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@media (max-width: 640px) {
  .toast-host {
    top:auto;
    bottom:18px;
    right:12px;
    left:12px;
    width:auto;
  }
}

.warning {
  background:var(--color-earth-250);
  border-color:var(--color-earth-550);
  border-left-color:var(--warning);
}

.flow-steps {
  list-style:none;
  padding:0;
  margin:0;
  display:grid;
  grid-template-columns:repeat(2, minmax(0, 1fr));
  gap:10px;
}

@media (min-width: 640px) {
  .flow-steps {
    grid-template-columns:repeat(4, minmax(0, 1fr));
  }
}

.flow-steps li {
  display:flex;
  flex-direction:column;
  align-items:center;
  text-align:center;
  gap:8px;
  background:var(--surface-soft);
  border:1px solid var(--line);
  padding:12px 10px;
  border-radius:var(--radius);
  transition:border-color .15s ease, box-shadow .15s ease;
}

.flow-steps li:hover {
  border-color:var(--alpha-info-25);
  box-shadow:0 4px 12px var(--alpha-info-8);
}

.flow-steps li span {
  font-size:var(--text-12);
  font-weight:600;
  color:var(--secondary);
}

.flow-steps strong {
  display:grid;
  place-items:center;
  width:32px;
  height:32px;
  border-radius:var(--radius-round);
  background:var(--primary);
  color:var(--color-neutral-50);
  font-size:var(--text-13);
}

.muted {
  color:var(--muted);
}

label {
  display:block;
  font-size:var(--text-13);
  color:var(--muted);
  margin-bottom:6px;
}

input[type="file"] {
  border-style:dashed;
  border-color:var(--alpha-info-35);
  background:var(--surface-soft);
  padding:12px;
}

input,
select {
  width:100%;
  padding:10px 12px;
  border:1px solid var(--color-neutral-200);
  border-radius:var(--radius);
  margin-bottom:12px;
  background:white;
  color:var(--ink);
}

input[type="file"]::file-selector-button {
  margin-right:12px;
  border:none;
  border-radius:var(--radius);
  background:var(--primary);
  color:var(--color-neutral-50);
  padding:8px 12px;
  font-weight:700;
  cursor:pointer;
}

input:focus,
select:focus,
textarea:focus {
  outline:2px solid var(--alpha-info-18);
  border-color:var(--primary);
}

button {
  border:none;
  background:var(--primary);
  color:white;
  padding:10px 14px;
  border-radius:var(--radius);
  cursor:pointer;
  text-decoration:none;
  font-weight:700;
  display:inline-block;
}

button:hover { background:var(--primary-dark); }

button:active { transform:scale(0.99); }

.compile-button { width:100%; }

.compile-button.is-loading {

  pointer-events:none;
}

.btn-spinner {
  display:inline-block;
  width:14px;
  height:14px;
  margin-right:8px;
  border:2px solid var(--alpha-surface-35);
  border-top-color:var(--color-neutral-50);
  border-radius:var(--radius-round);
  vertical-align:-2px;
  animation:compile-spin .7s linear infinite;
}

.editor-save-action.is-loading {

  pointer-events:none;
}button.is-loading:not(.compile-button) {
  cursor:wait;
  opacity:0.92;
  pointer-events:none;
}

.editor-save-action .btn-spinner,
button.is-loading:not(.compile-button) .btn-spinner {
  border-color:var(--alpha-surface-35);
  border-top-color:var(--color-neutral-50);
}

@keyframes compile-spin {
  to { transform: rotate(360deg); }
}

body.is-page-loading {
  overflow:hidden;
}

@keyframes loader-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes loader-pop-in {
  from {
    opacity: 0;
    transform: translateY(8px) scale(.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.workspace.is-busy {
  pointer-events:none;
  user-select:none;
}

.workspace.is-busy .editor-area--ide {
  opacity:0.92;
}

.status-dot.is-busy {
  background:var(--color-earth-850);
  box-shadow:0 0 0 4px var(--alpha-warning-18);
  animation:status-pulse 1.1s ease-in-out infinite;
}

@keyframes status-pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.12); opacity: 0.82; }
}

.file-tree.is-loading {
  opacity:0.72;
}

.editor-form.is-loading textarea {
  opacity:0.72;
  cursor:wait;
}

.compile-panel__body.is-compiling .status-grid {
  opacity:0.78;
}

@keyframes compile-progress-slide {
  0% { transform: translateX(-120%); }
  100% { transform: translateX(320%); }
}

.page-project {
  background:var(--bg);
}

.workspace {
  display:grid;
  grid-template-columns:300px minmax(0, 1fr) 410px;
  height:calc(100vh - 84px);
  border-top:1px solid var(--line);
}

.sidebar,
.compile-panel {
  background:white;
  border-right:1px solid var(--line);
  overflow:hidden;
}

.sidebar {
  display:flex;
  flex-direction:column;
  padding:0;
}

.sidebar-header {
  padding:18px;
  border-bottom:1px solid var(--line);
  flex-shrink:0;
}

.sidebar-header .file-search {
  margin-bottom:0;
}

.sidebar-footer {
  flex-shrink:0;
  padding:12px 18px 18px;
  border-top:1px solid var(--line);
  display:grid;
  gap:10px;
}

.compile-panel {
  border-right:none;
  border-left:1px solid var(--line);
  display:flex;
  flex-direction:column;
  padding:0;
}

.compile-panel__header {
  padding:18px;
  border-bottom:1px solid var(--line);
  flex-shrink:0;
}

.compile-panel__body {
  flex:1;
  overflow:auto;
  padding:18px;
}

.compile-panel__body .status-grid {
  margin-top:0;
}

.compile-panel__body form {
  margin-bottom:10px;
}

.status-dot {
  width:10px;
  height:10px;
  border-radius:var(--radius-round);
  background:var(--success);
  box-shadow:0 0 0 4px var(--alpha-shadow-12);
  margin-top:8px;
}

.file-search {
  margin-bottom:10px;
}

.file-tree {
  flex:1;
  min-height:0;
  overflow:auto;
  padding:12px 18px;
  max-height:none;
}

.tree-list {
  list-style:none;
  margin:0;
  padding:0;
}

.tree-root {
  display:grid;
  gap:3px;
}

.tree-children {
  margin-left:11px;
  padding-left:8px;
  border-left:1px dashed var(--color-blue-150);
}

.tree-node[hidden] {
  display:none!important;
}

.tree-directory {
  margin:2px 0;
}

.tree-summary {
  display:flex;
  align-items:center;
  gap:6px;
  padding:7px 8px;
  border-radius:var(--radius);
  cursor:pointer;
  user-select:none;
  color:var(--color-blue-550);
  font-size:var(--text-13);
  min-width:0;
}

.tree-summary:hover {
  background:var(--color-blue-50);
}

.tree-directory.contains-active > details > .tree-summary {
  color:var(--primary-dark);
  font-weight:800;
}

.tree-directory details[open] > .tree-summary .tree-chevron {
  transform:rotate(90deg);
}

.tree-chevron {
  display:inline-flex;
  width:10px;
  justify-content:center;
  font-size:var(--text-11);
  color:var(--color-neutral-550);
  transition:transform .15s ease;
}

.tree-name {
  min-width:0;
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
}

.tree-file {
  margin:2px 0;
}

.tree-file small {
  opacity:.72;
  white-space:nowrap;
  margin-left:auto;
  font-size:var(--text-11);
}

.mini-section {
  background:var(--surface-soft);
  border:1px solid var(--line);
  border-radius:var(--radius);
  padding:10px;
  margin-bottom:10px;
}

.mini-section summary {
  cursor:pointer;
  font-weight:800;
}

.mini-section form { margin-top:10px; }

.editor-area {
  min-width:0;
  background:var(--color-neutral-50);
}

/* layout tokens live in the IDE block below */

.editor-form {
  flex:1 1 auto;
  width:100%;
  min-width:0;
  min-height:0;
  display:flex;
  flex-direction:column;
  overflow:hidden;
}

textarea {
  flex:1;
  width:100%;
  border:0;
  resize:none;
  padding:18px;
  font-family:Consolas, Monaco, "Courier New", monospace;
  font-size:var(--text-14);
  line-height:1.55;
  outline:0;
  background:var(--color-neutral-50);
  color:var(--color-blue-700);
}

.editor-area--ide textarea {
  background:transparent;
  color:transparent;
  -webkit-text-fill-color:transparent;
  cursor:text;
  user-select:text;
  -webkit-user-select:text;
}

.editor-form.is-loading textarea[readonly] {
  pointer-events:none;
  cursor:wait;
}

.status-grid {
  display:grid;
  grid-template-columns:1fr 1fr;
  gap:10px;
  margin-bottom:14px;
}

.status-grid.compact {
  grid-template-columns:1fr 1fr 1fr;
}

.hint {
  margin-top:12px;
  background:var(--color-earth-250);
  border-left:4px solid var(--warning);
  padding:10px;
  border-radius:var(--radius);
  font-size:var(--text-13);
  color:var(--color-earth-1350);
}

.compile-status {
  margin:14px 0;
  padding:10px;
  border-radius:var(--radius);
  font-weight:800;
}

.compile-status.ok { background:var(--color-green-50); color:var(--success); }
.compile-status.fail { background:var(--color-red-50); color:var(--color-red-350); }

.issue-list {
  background:var(--surface-soft);
  border:1px solid var(--line);
  border-radius:var(--radius);
  padding:10px 14px 10px 28px;
  font-size:var(--text-13);
}
.issue-list li { margin-bottom:6px; }

.log-toolbar {
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
  margin-top:12px;
}

.log-toolbar h3 { margin:0; }

.log,
.command {
  background:var(--color-blue-750);
  color:var(--color-neutral-200);
  border-radius:var(--radius);
  padding:12px;
  font-size:var(--text-12);
  max-height:56vh;
  overflow:auto;
  white-space:pre-wrap;
}

.log.is-hidden { display:none; }

.table-wrap { overflow-x:auto; }

code {
  background:var(--color-blue-50);
  color:var(--color-blue-450);
  padding:2px 5px;
  border-radius:var(--radius-xs);
}

hr {
  border:none;
  border-top:1px solid var(--line);
  margin:18px 0;
}

@media (max-width: 1180px) {
  .workspace { grid-template-columns:260px minmax(0, 1fr); height:auto; min-height:calc(100vh - 84px); }
  .workspace:not(.workspace--ide) .compile-panel { grid-column:1 / -1; height:auto; max-height:none; }
  .file-tree { max-height:50vh; }
}

@media (max-width: 760px) {
  .workspace:not(.workspace--ide) { display:block; height:auto; min-height:calc(100vh - 84px); }
  .workspace:not(.workspace--ide) .sidebar,
.workspace:not(.workspace--ide) .compile-panel { border:none; border-bottom:1px solid var(--line); max-height:none; }
  .file-tree { max-height:42vh; flex:none; }
  .status-grid,
.status-grid.compact { grid-template-columns:1fr; }


}
