/* SHINHA Form Tools — App base */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  color: #1a1a2e;
  background: #f0f2f5;
  line-height: 1.5;
}

a {
  color: #1a4b8c;
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

img {
  max-width: 100%;
  height: auto;
}

/* Header */
.app-header {
  background: #fff;
  border-bottom: 1px solid #dde1e8;
  padding: 0 20px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
}

.app-header__brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 18px;
  color: #1a4b8c;
}

.app-header__brand span {
  font-weight: 400;
  font-size: 13px;
  color: #5a6270;
}

.app-header__nav {
  display: flex;
  gap: 16px;
  align-items: center;
}

.app-header__nav a {
  font-size: 14px;
  font-weight: 500;
}

/* Beta banner */
.beta-banner {
  display: none;
  background: linear-gradient(90deg, #1a4b8c, #2d6cb5);
  color: #fff;
  padding: 10px 20px;
  font-size: 13px;
  text-align: center;
}

.beta-banner.is-visible {
  display: block;
}

.beta-banner strong {
  font-weight: 700;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  font-size: 14px;
  font-weight: 600;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s, opacity 0.15s;
  font-family: inherit;
  white-space: nowrap;
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-primary {
  background: #1a4b8c;
  color: #fff;
}

.btn-primary:hover:not(:disabled) {
  background: #153d72;
}

.btn-secondary {
  background: #e8ecf1;
  color: #1a1a2e;
}

.btn-secondary:hover:not(:disabled) {
  background: #d5dbe3;
}

.btn-accent {
  background: #2d8a4e;
  color: #fff;
}

.btn-accent:hover:not(:disabled) {
  background: #247040;
}

.btn-sm {
  padding: 5px 10px;
  font-size: 12px;
}

.btn-icon {
  width: 36px;
  height: 36px;
  padding: 0;
  font-size: 18px;
}

/* Tool page: chrome in normal flow; layout fills remaining viewport */
body.page-tool {
  display: flex;
  flex-direction: column;
  height: 100vh;
  max-height: 100vh;
  overflow: hidden;
  min-height: 0;
}

body.page-tool .app-header,
body.page-tool .beta-banner,
body.page-tool .tool-toolbar,
body.page-tool .mobile-tool-actions {
  flex-shrink: 0;
}

/* Tool layout */
.tool-layout {
  display: grid;
  grid-template-columns: 420px 1fr;
  flex: 1 1 auto;
  min-height: 0;
  height: auto;
  overflow: hidden;
}

.tool-sidebar {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-right: 1px solid #dde1e8;
  background: #fff;
}

.form-panel {
  flex: 1;
  min-height: 0;
}

.customize-launcher {
  display: none;
}

.export-panel {
  display: none;
}

.preview-edit-hint {
  display: none;
  margin: 0;
  padding: 8px 14px;
  font-size: 12px;
  color: #5a6270;
  background: #fff8e6;
  border-bottom: 1px solid #f0e4c8;
  line-height: 1.4;
}

.preview-edit-hint__icon {
  margin-right: 4px;
}

.preview-mobile-actions {
  display: none;
  padding: 10px 14px;
  border-top: 1px solid #dde1e8;
  background: #fff;
}

.mobile-tab-bar {
  display: none;
}

.mobile-sticky-bar {
  display: none;
}

.mobile-tool-actions {
  display: none;
}

.mobile-export-footer {
  display: none;
}

.mobile-tool-actions__row {
  display: flex;
  width: 100%;
}

.mobile-only-btn {
  display: none;
}

.tool-layout.is-form-hidden {
  grid-template-columns: 0 1fr;
}

.tool-layout.is-form-hidden .tool-sidebar,
#formPanel[hidden] {
  display: none !important;
}

.tool-layout.is-form-hidden .preview-area {
  grid-column: 1 / -1;
}

#toggleFormButton.is-active {
  background: #eaf2ff;
  color: #064a9b;
  border-color: #1f5fbf;
}

/* Toolbar */
.tool-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: #fff;
  border-bottom: 1px solid #dde1e8;
  flex-wrap: wrap;
}

.tool-toolbar__group {
  display: flex;
  align-items: center;
  gap: 6px;
}

.tool-toolbar__divider {
  width: 1px;
  height: 24px;
  background: #dde1e8;
  margin: 0 4px;
}

.tool-toolbar__label {
  font-size: 13px;
  color: #5a6270;
}

.tool-toolbar__group--template {
  position: relative;
}

/* Template quick switcher */
.template-switcher {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.template-switcher-button {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 32px;
  padding: 7px 10px;
  border: 1px solid #d7deea;
  border-radius: 6px;
  background: #ffffff;
  color: #064a9b;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.2;
  cursor: pointer;
  white-space: nowrap;
  font-family: inherit;
}

.template-switcher-button:hover {
  background: #f3f7ff;
  border-color: #2f6fbe;
  color: #003f88;
}

.template-switcher-button:focus-visible {
  outline: 2px solid #1f5fbf;
  outline-offset: 2px;
}

.template-switcher.is-open .template-switcher-button {
  background: #eaf2ff;
  border-color: #1f5fbf;
  box-shadow: 0 0 0 2px rgba(47, 111, 190, 0.12);
}

.template-switcher-caret {
  font-size: 11px;
  color: #64748b;
  line-height: 1;
}

.template-switcher-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 9999;
  width: 260px;
  max-width: calc(100vw - 24px);
  max-height: 360px;
  overflow-y: auto;
  padding: 8px;
  background: #ffffff;
  border: 1px solid #d7deea;
  border-radius: 10px;
  box-shadow: 0 16px 36px rgba(15, 42, 74, 0.18);
}

.template-switcher-menu[hidden] {
  display: none;
}

.template-switcher-option {
  appearance: none;
  width: 100%;
  border: 0;
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 10px;
  border-radius: 8px;
  color: #1f2937;
  font-size: 13px;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  font-family: inherit;
}

.template-switcher-option:hover,
.template-switcher-option:focus-visible {
  background: #f3f7ff;
  color: #064a9b;
  outline: none;
}

.template-switcher-option.is-active {
  background: #eaf2ff;
  color: #064a9b;
  font-weight: 800;
}

.template-switcher-current-badge {
  flex: 0 0 auto;
  padding: 3px 7px;
  border-radius: 999px;
  background: #dbeafe;
  color: #2563eb;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

/* Preview area wrapper */
.preview-area {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: #c8cdd6;
}

/* Toast */
.shinha-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: #1a1a2e;
  color: #fff;
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 14px;
  z-index: 9999;
  opacity: 0;
  transition: transform 0.25s, opacity 0.25s;
  pointer-events: none;
  max-width: 90vw;
  text-align: center;
}

.shinha-toast.is-visible {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

.shinha-toast--success { background: #2d8a4e; }
.shinha-toast--error { background: #c0392b; }
.shinha-toast--info { background: #1a4b8c; }
.shinha-toast--warning { background: #b45309; }

/* Watermark */
.shinha-watermark {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) rotate(-35deg);
  font-size: 36px;
  font-weight: 900;
  color: rgba(0, 0, 0, 0.08);
  pointer-events: none;
  white-space: nowrap;
  z-index: 10;
  letter-spacing: 4px;
}

/* Index page */
.page-index .hero {
  background: linear-gradient(135deg, #1a4b8c 0%, #2d6cb5 100%);
  color: #fff;
  padding: 48px 24px;
  text-align: center;
}

.page-index .hero h1 {
  font-size: 32px;
  margin: 0 0 12px;
}

.page-index .hero p {
  font-size: 16px;
  opacity: 0.9;
  max-width: 640px;
  margin: 0 auto 24px;
}

.page-index .container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 32px 20px;
}

.page-index .section-title {
  font-size: 22px;
  font-weight: 700;
  margin: 0 0 8px;
  color: #1a4b8c;
}

.page-index .section-desc {
  color: #5a6270;
  margin: 0 0 24px;
  font-size: 14px;
}

.template-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
}

.template-card {
  background: #fff;
  border-radius: 10px;
  border: 1px solid #dde1e8;
  padding: 20px;
  transition: box-shadow 0.2s, border-color 0.2s;
}

.template-card:hover {
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
}

.template-card--active {
  border-color: #1a4b8c;
}

.template-card--soon {
  opacity: 0.7;
}

.template-card__id {
  font-size: 11px;
  color: #888;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.template-card__name {
  font-size: 16px;
  font-weight: 700;
  margin: 6px 0 8px;
}

.template-card__badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 10px;
  background: #e8ecf1;
  color: #5a6270;
}

.template-card__badge--beta {
  background: #d4edda;
  color: #247040;
}

.template-card__badge--soon {
  background: #fff3cd;
  color: #856404;
}

.template-card__action {
  margin-top: 14px;
}

.page-index .footer {
  text-align: center;
  padding: 24px;
  color: #888;
  font-size: 13px;
  border-top: 1px solid #dde1e8;
  margin-top: 32px;
}
