/* Layout */
.tg-container { display: flex; flex-direction: column; gap: 1rem; }

/* Toolbar */
.tg-toolbar {
  display: flex; justify-content: space-between; align-items: center;
  flex-wrap: wrap; gap: 0.6rem;
}
.tg-toolbar-left, .tg-toolbar-right { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.tg-add-row, .tg-add-col { font-size: 0.82rem; padding: 0.35rem 0.75rem; }
.tg-del-row, .tg-del-col {
  font-size: 0.82rem; padding: 0.35rem 0.75rem;
  background: rgba(255,100,100,0.08); border-color: rgba(255,100,100,0.2); color: #ff8fa3;
}
.tg-del-row:hover, .tg-del-col:hover { background: rgba(255,100,100,0.15); }
.tg-check {
  display: flex; align-items: center; gap: 0.4rem;
  font-size: 0.82rem; cursor: pointer; opacity: 0.8;
}
.tg-check input { accent-color: var(--accent); width: 15px; height: 15px; cursor: pointer; }
.tg-csv-import { font-size: 0.82rem; padding: 0.35rem 0.8rem; }

/* Editor */
.tg-editor-card { padding: 0; overflow: hidden; }
.tg-table-wrap { overflow: auto; }
.tg-table { border-collapse: collapse; width: 100%; min-width: 400px; }
.tg-table td, .tg-table th {
  border: 1px solid rgba(255,255,255,0.1);
  padding: 0; min-width: 100px;
}
.tg-table th { background: rgba(255,255,255,0.05); }
.tg-cell {
  width: 100%; box-sizing: border-box;
  background: transparent; border: none; outline: none;
  color: inherit; font-family: inherit; font-size: 0.88rem;
  padding: 0.55rem 0.75rem; min-width: 100px;
  resize: none; display: block;
}
.tg-table th .tg-cell { font-weight: 700; }
.tg-cell:focus { background: rgba(255,255,255,0.04); }
.tg-table tr:nth-child(even) td { background: rgba(255,255,255,0.02); }
.tg-row-del-cell { border: none !important; padding: 0 4px !important; min-width: 0 !important; text-align: center; }
.tg-row-del {
  background: none; border: none; color: rgba(255,255,255,0.3); cursor: pointer;
  font-size: 0.95rem; line-height: 1; padding: 4px 6px; border-radius: 6px; transition: all .15s;
}
.tg-row-del:hover { color: #ff6b8a; background: rgba(255,107,138,.12); }
.tg-row-del:disabled { visibility: hidden; }

/* Output */
.tg-output-card { padding: 1rem; }
.tg-out-tabs { display: flex; gap: 0.4rem; margin-bottom: 0.75rem; }
.tg-out-tab {
  background: rgba(255,255,255,0.05); border: 1px solid rgba(255,255,255,0.1);
  color: inherit; border-radius: 7px; padding: 0.3rem 0.75rem;
  font-size: 0.82rem; font-weight: 600; cursor: pointer;
  transition: background 0.15s;
}
.tg-out-tab.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.tg-code-wrap { position: relative; }
.tg-code {
  background: rgba(0,0,0,0.3); border: 1px solid rgba(255,255,255,0.08);
  border-radius: 10px; padding: 1rem; padding-right: 4.5rem;
  font-size: 0.82rem; font-family: 'SF Mono','Fira Code',monospace;
  white-space: pre; overflow-x: auto;
  margin: 0; min-height: 60px; line-height: 1.65;
}
.tg-copy-btn {
  position: absolute; top: 0.6rem; right: 0.6rem;
  font-size: 0.78rem; padding: 0.3rem 0.7rem;
}
.tg-download-btn {
  position: absolute; top: 0.6rem; right: 5.4rem;
  font-size: 0.78rem; padding: 0.3rem 0.7rem;
}

/* Modal */
.tg-modal {
  position: fixed; inset: 0; background: rgba(0,0,0,0.65);
  display: flex; align-items: center; justify-content: center; z-index: 100;
}
.tg-modal-inner { padding: 1.5rem; width: 480px; max-width: calc(100vw - 2rem); }
.tg-modal-title { font-size: 1rem; font-weight: 700; margin-bottom: 0.9rem; }
.tg-csv-input {
  width: 100%; box-sizing: border-box;
  background: rgba(0,0,0,0.2); border: 1px solid rgba(255,255,255,0.1);
  border-radius: 8px; padding: 0.75rem;
  color: inherit; font-family: 'SF Mono','Fira Code',monospace;
  font-size: 0.85rem; resize: vertical; outline: none;
  margin-bottom: 0.9rem;
}
.tg-csv-input:focus { border-color: var(--accent); }
.tg-modal-btns { display: flex; gap: 0.5rem; }
